Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Like "Angry" or "Happy" or "fearful", I remember I saw a program long ago with a multiline textbox and the ability to select some text and choose with what emotion to say the selected text, with ability of more than one emotion in each text.

I want this ability in coding with C#, appending each time a text to be spoken with a different emotion.

Also, if you know of such a 3rd party program also include its name please.

What I have tried:

SPvoice SP = new SPvoice();
SP.Speak("Hello world");
Posted
Updated 6-Jun-21 17:25pm
v2
Comments
[no name] 6-Jun-21 11:27am    
https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-synthesis-markup?tabs=csharp
john1990_1 6-Jun-21 11:39am    
Please submit as an answer, please also recommend a video teaching how to deal with XML to make voice, when I know only C# .NET WinForms and Console.
[no name] 6-Jun-21 12:16pm    
I learned from the docs (no videos). That's my "comment".
john1990_1 6-Jun-21 12:18pm    
I don't even know where to write the XML code and how... if you would recommend a video I would be happy otherwise I would just try to search on my own.
[no name] 6-Jun-21 22:08pm    
The SSML "wraps" the speech text you want to treat. Where the speech synthesizer refers to text, include text with SSML.

1 solution

string phrase = @"<speak version=""1.0""
  http://www.w3.org/2001/10/synthesis""
  xml:lang=""en-US"">";
phrase += @"<say-as interpret-as=""ordinal"">3rd</say-as>";
phrase += @"<break time=""1s""/>";
phrase += @"<say-as interpret-as=""cardinal"">3rd</say-as>";
phrase += @"</speak>";
synthesizer.SpeakSsml(phrase);

https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/june/speech-text-to-speech-synthesis-in-net
 
Share this answer
 
Comments
john1990_1 7-Jun-21 10:16am    
Thx, but I'm having a bug:

System.FormatException
HResult=0x80131537
Message=XML content not valid.
Source=System.Speech
StackTrace:
at System.Speech.Internal.Synthesis.VoiceSynthesis.Speak(Prompt prompt)
at System.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
at System.Speech.Synthesis.SpeechSynthesizer.SpeakSsml(String textToSpeak)
at AppTestSpeechEmotions.Form1..ctor() in C:\Users\roberto\source\repos\AppTestSpeechEmotions\AppTestSpeechEmotions\Form1.cs:line 30
at AppTestSpeechEmotions.Program.Main() in C:\Users\roberto\source\repos\AppTestSpeechEmotions\AppTestSpeechEmotions\Program.cs:line 19

This exception was originally thrown at this call stack:
System.Xml.XmlTextReaderImpl.Throw(System.Exception)
System.Xml.XmlTextReaderImpl.Throw(string, string[])
System.Xml.XmlTextReaderImpl.ParseQName(bool, int, out int)
System.Xml.XmlTextReaderImpl.ParseAttributes()
System.Xml.XmlTextReaderImpl.ParseElement()
System.Xml.XmlTextReaderImpl.ParseDocumentContent()
System.Xml.XmlTextReaderImpl.Read()
System.Xml.XmlTextReader.Read()
System.Speech.Internal.Synthesis.SsmlParser.Parse(System.Xml.XmlReader, System.Speech.Internal.Synthesis.ISsmlParser, object)

Inner Exception 1:
XmlException: Name cannot begin with the '/' character, hexadecimal value 0x2F. Line 1, position 30.
[no name] 8-Jun-21 12:13pm    
You have to show your SSML. It says it's "not valid".
john1990_1 8-Jun-21 12:19pm    
I used the exact code you provided.
[no name] 8-Jun-21 12:37pm    
I showed you "where" (SpeakSSml). That's it. As for the rest, I don't see any of "your" code.
john1990_1 8-Jun-21 12:58pm    
https://prnt.sc/14qiotw

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900