Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to create MULTIPLE TTS "wav" files using MS-SAPI 5.1 in C#
    primarykey
    data
    text
    <p>Greetings folks!</p> <p>I'm working on a project where I will have to create WAV files of names using TTS.</p> <p>I have the MS-SAPI 5.1 SDK installed on a Windows Server 2003 and use C# to write the TTS program. Apart from the default Microsoft Sam voice, I have voices from NeoSpeech TTS installed on the server.</p> <p>The issue I'm having is, <strong>the program does not produce more than 1 working WAV file</strong>.</p> <p>To be more specific, if I send 4 names to the program, the program creates 4 WAV files. However only the first name is converted correctly. The file size is greater than 1 kb and the file also plays in media player.</p> <p>The other 3 files are created but are of size 1 kb and do not work in any media player.</p> <p>I'm new to both C# and MS-SAPI but I believe I have done a decent job creating the code. I have spent days trying to figure this out but I'm out of energy now.</p> <p>Any insight on this issue is greatly appreciated. Thanks for your time.</p> <p>Here is my code:</p> <pre><code>using System; using System.Collections.Generic; using System.Collections; using System.Text; using SpeechLib; using System.Threading; namespace TTS_Text_To_Wav { class Gender { public static String MALE = "Male"; public static String FEMALE = "Female"; } class Languages { public static String ENGLISH = "409;9"; public static String SPANISH = "40a"; } class Vendor { public static String VOICEWARE = "Voiceware"; public static String MICROSOFT = "Microsoft"; } class SampleTTS { static void Main(string[] args) { SampleTTS processor = null; try { processor = new SampleTTS(); // get unprocessed items ArrayList unProcessedItems = new ArrayList(); unProcessedItems.Add("Kate"); unProcessedItems.Add("Sam"); unProcessedItems.Add("Paul"); unProcessedItems.Add("Violeta"); if (unProcessedItems != null) { foreach (string record in unProcessedItems) { // convert text to wav processor.ConvertStringToSpeechWav(record, "c:/temp/" + record + ".wav", Vendor.VOICEWARE, Gender.MALE, Languages.ENGLISH); } } } catch (Exception e) { Console.WriteLine(e.Message); } } void ConvertStringToSpeechWav(String textToConvert, String pathToCreateWavFile, String vendor, String gender, String language) { SpVoice voice = null; SpFileStream spFileStream = null; try { spFileStream = new SpFileStream(); voice = new SpVoice(); spFileStream.Format.Type = SpeechAudioFormatType.SAFT8kHz16BitMono; spFileStream.Open(pathToCreateWavFile, SpeechStreamFileMode.SSFMCreateForWrite, false); voice.Voice = voice.GetVoices("Vendor=" + vendor + ";Gender=" + gender, "Language=" + language).Item(0); voice.AudioOutputStream = spFileStream; voice.Speak(textToConvert, SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); voice.WaitUntilDone(Timeout.Infinite); } catch (Exception e) { throw new Exception("Error occured in ConvertStringToSpeechWav()\n" + e.Message); } finally { if (spFileStream != null) { spFileStream.Close(); } } } } } </code></pre> <p><strong>Edit:</strong></p> <p>I seem to notice some new behavior. The code works fine for Microsoft voices on the system. It is only with the NeoSpeech voices I seem to have this issue.</p> <p>Does that mean my code is correct and something is wrong with the voices? For one, I got the voice from my clients so there is nothing I can do about it. Secondly these are production ready voices. I'm pretty sure they are well tested or we would have heard a lot about it.</p> <p>I'm still inclined to believe something is up with the code I wrote.</p> <p>Are there any other suggestions available? I'm in a real fix here and any help will be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload