Skip to content

Commit

Permalink
First Draft of TTS moth SP movemeny is in working order and tested.
Browse files Browse the repository at this point in the history
  • Loading branch information
AccidentalCitizen committed Apr 7, 2024
1 parent f9acada commit 6a7da88
Show file tree
Hide file tree
Showing 19 changed files with 877 additions and 24 deletions.
17 changes: 16 additions & 1 deletion src/AI.TTS.Visual/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 25 additions & 23 deletions src/AI.TTS.Visual/FormMain.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
Expand All @@ -16,26 +11,27 @@ namespace AI.TTS.Visual
{
public partial class FormMain : Form
{

public FormMain()
{
InitializeComponent();
}

private void FormMain_Load(object sender, EventArgs e)
{
string textfilePath = "path/to/your/text/file.txt";
string outputVideoFilePath = "";
string textfilePath = @"C:\Users\Rajah\Documents\Test Data\TextScripts\input.txt";
string outputVideoFilePath = @"C:\Users\Rajah\Documents\Test Data\TextScripts\output.mp4";

double ScaleFactor = 0.3;

// Initialize video writer

// Start recording images
ImageDisplay imageDisplay = new ImageDisplay(outputVideoFilePath);
VideoWriter writer = imageDisplay.writer; // Sharing the writer,
//ImageDisplay imageDisplay = new ImageDisplay(outputVideoFilePath);
//VideoWriter writer = imageDisplay.writer; // Sharing the writer,

Thread imageDisplayThread = new Thread(imageDisplay.StartRecording);
imageDisplayThread.Start();
//Thread imageDisplayThread = new Thread(imageDisplay.StartRecording);
//imageDisplayThread.Start();

// Read the text from the file
string text = File.ReadAllText(textfilePath);
Expand All @@ -50,8 +46,9 @@ private void FormMain_Load(object sender, EventArgs e)
foreach (char c in word)
{
// Check if the character is a vowel
WriteImagePerVowel(ScaleFactor, writer, c);

// WriteImagePerVowel(ScaleFactor, writer, c);
var bitmap = GetMouthImage(c);
this.pictureBox.Image = bitmap;
// Adjust the delay to simulate the speed of human speech for characters
Thread.Sleep(100);
}
Expand All @@ -60,11 +57,11 @@ private void FormMain_Load(object sender, EventArgs e)
}

// Stop recording images
imageDisplay.StopRecording();
imageDisplayThread.Join();
//imageDisplay.StopRecording();
//imageDisplayThread.Join();

// Release the video writer
writer.Dispose();
// writer.Dispose();
}

private static void WriteImagePerVowel(double ScaleFactor, VideoWriter writer, char c)
Expand All @@ -81,7 +78,7 @@ private static void WriteImagePerVowel(double ScaleFactor, VideoWriter writer, c
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(mouthImage, 0, 0, scaledMouthImage.Width, scaledMouthImage.Height);
}

// Convert the Bitmap to Image<Bgr, byte>
Image<Bgr, byte> emguImage = ImageDisplay.EmguImageFromBitmap(scaledMouthImage);

Expand All @@ -97,24 +94,29 @@ static Bitmap GetMouthImage(char vowel)
{
case 'A':
case 'a':
return new Bitmap("mouth_a.bmp");
return new Bitmap(@"C:\Users\Rajah\Pictures\SpMouths\A.png");
case 'E':
case 'e':
return new Bitmap("mouth_e.bmp");
return new Bitmap(@"C:\Users\Rajah\Pictures\SpMouths\E.png");
case 'I':
case 'i':
return new Bitmap("mouth_i.bmp");
return new Bitmap(@"C:\Users\Rajah\Pictures\SpMouths\I.png");
case 'O':
case 'o':
return new Bitmap("mouth_o.bmp");
return new Bitmap(@"C:\Users\Rajah\Pictures\SpMouths\O.png");
case 'U':
case 'u':
return new Bitmap("mouth_u.bmp");
return new Bitmap(@"C:\Users\Rajah\Pictures\SpMouths\U.png");
case ' ':
return new Bitmap("partialOpenMouth.bmp");
return new Bitmap(@"C:\Users\Rajah\Pictures\SpMouths\L.png");
default:
return null;
}
}

private void pictureBox_Click(object sender, EventArgs e)
{

}
}
}
14 changes: 14 additions & 0 deletions src/ActuarialIntelligence.sln
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.TTS.EXE", "AI.TTS.EXE\AI
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AI.TTS.Visual", "AI.TTS.Visual\AI.TTS.Visual.csproj", "{26F4EDC1-05BA-41FE-BE71-71DB0E3C5C8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTTSAi", "BasicTTSAi\BasicTTSAi.csproj", "{34AD0CD5-C5D9-43B5-8290-C331434A343A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTTS", "BasicTTS\BasicTTS.csproj", "{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -177,6 +181,14 @@ Global
{26F4EDC1-05BA-41FE-BE71-71DB0E3C5C8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26F4EDC1-05BA-41FE-BE71-71DB0E3C5C8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26F4EDC1-05BA-41FE-BE71-71DB0E3C5C8D}.Release|Any CPU.Build.0 = Release|Any CPU
{34AD0CD5-C5D9-43B5-8290-C331434A343A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34AD0CD5-C5D9-43B5-8290-C331434A343A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34AD0CD5-C5D9-43B5-8290-C331434A343A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34AD0CD5-C5D9-43B5-8290-C331434A343A}.Release|Any CPU.Build.0 = Release|Any CPU
{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144}.Debug|Any CPU.Build.0 = Debug|Any CPU
{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144}.Release|Any CPU.ActiveCfg = Release|Any CPU
{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -204,6 +216,8 @@ Global
{BE18A29D-C80F-4C25-8D2A-59E1418F94E1} = {233764A4-5B6D-4144-A01C-092A136279FF}
{4F55C07A-6F34-4E59-96DF-7BDAE49804FE} = {846214C2-E1CC-4C1E-8F09-86BB5582072B}
{26F4EDC1-05BA-41FE-BE71-71DB0E3C5C8D} = {846214C2-E1CC-4C1E-8F09-86BB5582072B}
{34AD0CD5-C5D9-43B5-8290-C331434A343A} = {846214C2-E1CC-4C1E-8F09-86BB5582072B}
{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144} = {846214C2-E1CC-4C1E-8F09-86BB5582072B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7AFF1FB0-27A8-4765-900D-F53F52605824}
Expand Down
6 changes: 6 additions & 0 deletions src/BasicTTS/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
83 changes: 83 additions & 0 deletions src/BasicTTS/BasicTTS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{585E5FD4-CA9B-435E-9A8F-A5F6B2F5E144}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>BasicTTS</RootNamespace>
<AssemblyName>BasicTTS</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
76 changes: 76 additions & 0 deletions src/BasicTTS/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a7da88

Please sign in to comment.