Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .vs/TextToSpeech/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A windows forms text to speech program
[![License](https://img.shields.io/badge/License-Mit-blue.svg?style=for-the-badge&logo=mit)](LICENSE.md)


![alt text](https://github.com/bigboybamo/Text2speeech/blob/main/TextToSpeech/images/text_speech.JPG)
![alt text](https://github.com/bigboybamo/Text2speeech/blob/main/TextToSpeech/images/text_speech.png)

## Features
* Convert written text to spoken sentences.
Expand Down
22 changes: 22 additions & 0 deletions TextToSpeech/Common/ErrorMessages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TextToSpeech.Common
{
public static class ErrorMessages
{
public const string NoVoiceSelected = "Please select a voice.";
public const string NoTextProvided = "Please provide text to speak.";
public const string NoTextHighlighted = "Please Highlight Some Text.";
public const string TextStillSpeaking = "Please Wait for the current speech to finish or Stop.";
public const string ErrorOpeningFile = "There was an error opening the current file.";
public const string InvalidRate = "Invalid rate value. Please enter a value between -10 and 10.";
public const string InvalidVolume = "Invalid volume value. Please enter a value between 0 and 100.";
public const string FileNotFound = "The specified file was not found.";
public const string FileAlreadyExists = "The specified file already exists. Please choose a different name.";
public const string SaveAudioError = "Error saving audio file. Please check the file path and permissions.";
}
}
32 changes: 31 additions & 1 deletion TextToSpeech/Form1.Designer.cs

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

30 changes: 24 additions & 6 deletions TextToSpeech/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using TextToSpeech.Interfaces;
using TextToSpeech.Implementations;
using TextToSpeechLogger;
using TextToSpeech.Common;

namespace TextToSpeech
{
Expand All @@ -17,6 +18,7 @@ public Form1()
// Set the form size
this.Height = 600;
this.Width = 1000;
StartTimer();
}

private ISpeechSynthesizer synthVoice;
Expand Down Expand Up @@ -110,7 +112,7 @@ private void BtnOpenFile_Click(object sender, EventArgs e)
}
else
{
MessageBox.Show("Error");
MessageBox.Show(ErrorMessages.ErrorOpeningFile);
}
}
}
Expand Down Expand Up @@ -180,24 +182,24 @@ public void LoadVoices()

private void CheckVoiceandText(bool ishighLighted = false)
{
if (cmbVoice.Text == "Select Voice" || cmbVoice.SelectedIndex == 0)
if (cmbVoice.Text == ErrorMessages.NoVoiceSelected || cmbVoice.SelectedIndex == 0)
{
throw new InvalidOperationException("Please Select a Voice");
throw new InvalidOperationException(ErrorMessages.NoVoiceSelected);
}

if (txtSpechText.Text.Trim().Length == 0)
{
throw new InvalidOperationException("Please Enter Some Text");
throw new InvalidOperationException(ErrorMessages.NoTextProvided);
}

if (ishighLighted && txtSpechText.SelectionLength == 0)
{
throw new InvalidOperationException("Please Highlight Some Text");
throw new InvalidOperationException(ErrorMessages.NoTextHighlighted);
}

if (synthVoice.State == SynthesizerState.Speaking)
{
throw new InvalidOperationException("Please Wait for the current speech to finish or Stop");
throw new InvalidOperationException(ErrorMessages.TextStillSpeaking);
}
}

Expand All @@ -218,5 +220,21 @@ private void trackBar2_Scroll(object sender, EventArgs e)
synthVoice.RestartFromCurrentPosition(txtSpechText.Text);
}
}

private void StartTimer()
{
ClockTimer = new Timer
{
Interval = 500
};
ClockTimer.Tick += ClockTimer_Tick;
ClockTimer.Enabled = true;
}

private void ClockTimer_Tick(object sender, EventArgs e)
{
ClockLabel.Text = DateTime.Now.ToString("HH:mm:ss");
ClockLabel.Visible = true;
}
}
}
3 changes: 3 additions & 0 deletions TextToSpeech/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
<metadata name="ofd1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ClockTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>112, 22</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
2 changes: 2 additions & 0 deletions TextToSpeech/Implementations/SpeechSynthesizerWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Speech.Synthesis;
using TextToSpeech.Interfaces;
Expand Down Expand Up @@ -153,6 +154,7 @@ public void SaveAudioFile()
_speechSynthesizer.SetOutputToWaveFile(outputPath);
_speechSynthesizer.Speak(text);
_speechSynthesizer.SetOutputToNull();
Process.Start(textToSpeechPath);
}

~SpeechSynthesizerWrapper()
Expand Down
1 change: 1 addition & 0 deletions TextToSpeech/TextToSpeech.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\ErrorMessages.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
Binary file modified TextToSpeech/bin/Debug/TextToSpeech.exe
Binary file not shown.
Binary file modified TextToSpeech/bin/Debug/TextToSpeech.pdb
Binary file not shown.
Binary file modified TextToSpeech/bin/Release/TextToSpeech.exe
Binary file not shown.
Binary file modified TextToSpeech/bin/Release/TextToSpeech.pdb
Binary file not shown.
Binary file removed TextToSpeech/images/text_speech.JPG
Binary file not shown.
Binary file added TextToSpeech/images/text_speech.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified TextToSpeech/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
40cda065bc98d7a1ee342fa1d437a41d17d2c18a38d6ff112132fa3743a7c9d8
578f5453fd71c687fbf022c2f7134e2ea371e47b34b0d0953859fda1abe3e10d
Binary file not shown.
Binary file modified TextToSpeech/obj/Debug/TextToSpeech.exe
Binary file not shown.
Binary file modified TextToSpeech/obj/Debug/TextToSpeech.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified TextToSpeech/obj/Release/TextToSpeech.exe
Binary file not shown.
Binary file modified TextToSpeech/obj/Release/TextToSpeech.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
..\TextToSpeech\bin\Release\TextToSpeech.exe
..\TextToSpeechLogger\bin\Release\TextToSpeechLogger.dll
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\oyetu\source\repos\Text2speeech\TextToSpeechInstaller\bin\Release\en-us\TextToSpeechInstaller.msi
C:\Users\oyetu\source\repos\Text2speeech\TextToSpeechInstaller\bin\Release\en-us\TextToSpeechInstaller.wixpdb