Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>While I don't see anything glaring that is causing the TTS issue, there are some best practices and code simplifications you could be using.</p> <p>First off, the class which includes Main(), SampleTTS doesn't need to be instantiated in order to call ConvertStringToSpeechWav():</p> <pre><code>class SampleTTS { static void Main(string[] args) { SampleTTS processor = null; try { processor = new SampleTTS(); </code></pre> <p>The Sample TTS class can be rewritten as follows:</p> <pre><code>class SampleTTS { static void Main(string[] args) { try { // get unprocessed items List&lt;String&gt; unProcessedItems = new List&lt;String&gt;(); unProcessedItems.Add("Kate"); unProcessedItems.Add("Sam"); unProcessedItems.Add("Paul"); unProcessedItems.Add("Violeta"); foreach (string record in unProcessedItems) { // convert text to wav ConvertStringToSpeechWav(record, "c:/temp/" + record + ".wav", Vendor.VOICEWARE, Gender.MALE, Languages.ENGLISH); } } catch (Exception e) { Console.WriteLine(e.Message); } } </code></pre> <p>Note I also changed the list from <code>ArrayList -&gt; List&lt;String&gt;</code> as a best practice because List(T) performs better than ArrayList and is type safe. I also removed the <code>if (unProcessedItems != null check)</code> as you're already instantiating the list above, so it will either be non null or throw an exception.</p> <p>Lastly you're creating a new voice object each time <code>ConvertStringToSpeechWav()</code> is called:</p> <pre><code>voice = new SpVoice(); </code></pre> <p>and letting GC clean it up. Have you tried calling GC.Collect() like PauloPinto suggested above, just to see if it works? You don't have to stick to rigid coding principles just to get something working. The goal should always be to code cleanly and with principles, but more so to get your code in a working state, and then refactoring as needed.</p> <p>I hope some of this helps.</p> <p>Cheers.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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