none
SAPI not saying words correctly RRS feed

  • Question

  • Hello,

    I have a weather program that reads the forecast and conditions. However, the program will do the following:

    - Says "wines" instead of winds

    - Says the letters S S E for south southeast or S of south 

    - For the temperature is the forecast it will say for example 89 F instead of eighty nine.

    So, here is how a typical forecast would read:

    Lots of sunshine. A stray shower or thunderstorm is possible. High 92F. Winds S at 5 to 10 mph.

    Using the examples above, here is what the narriation would say:

    Lots of sunshine. A stray shower or thunderstorm is possible. High 9 2 F. Wines S at five to ten miles per hour.

    How can this issue be corrected?

    Saturday, July 28, 2018 7:13 PM

All replies

  • I don't have a good answer just saying I hear the same problems with the MS SpeechSynthesizer and voice Microsoft Anna.

    Perhaps if you can modify the text you can do some tricks. ie spell numbers eightyone south etc.

    You can try to use different voices perhaps one is better.

    Maybe there are 3rd party platforms that works better?

    PS this sounds better

    "High Ninety Two Degrees Fair in height. Winned South at five to ten miles per hour."

    Saturday, July 28, 2018 8:57 PM
  • In Win10 I don't hear the "wines" problem, but if it is an issue on a previous OS you should be able to fix it the same way you will fix the "F" and "S" issues, using a custom lexicon.

    First you have to create a lexicon XML file, something like:

    <?xml version="1.0" encoding="UTF-8"?>
    <lexicon version="1.0"
          xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
          alphabet="x-microsoft-ups" xml:lang="en-US">
      <lexeme>
        <grapheme> S </grapheme>
        <alias>south</alias>
      </lexeme>
      <lexeme>
        <grapheme>F </grapheme>
        <alias>farenheight</alias>
      </lexeme>
     
    </lexicon>

    Then you load that lexicon into the synthesizer:

    Private speaker As New Speech.Synthesis.SpeechSynthesizer()
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        speaker.AddLexicon(New Uri(My.Application.Info.DirectoryPath & "\SpeechLexicon.xml"), "application/pls+xml")
    End Sub
    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        speaker.Speak("Lots of sunshine. A stray shower or thunderstorm is possible. High 92F. Winds S at 5 to 10 mph.")
    End Sub
    
    More information on building a custom lexicon file can be found at https://www.w3.org/TR/pronunciation-lexicon/



    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Sunday, July 29, 2018 3:09 PM
    Moderator
  • Hi Reed!

    BTW. Its not saying wine, it is saying wind like wind the clock.  :)

    And I am running on windows 7.

    Sunday, July 29, 2018 3:41 PM
  • Hi Reed!

    BTW. Its not saying wine, it is saying wind like wind the clock.  :)

    And I am running on windows 7.

    Hi Tommy!

    OK, on Win10 it gets "wind" correct.  I would imagine an alias like "whind" would probably fix it on Win7.

    The only thing I'm not completely sure of is fixing the numbers (beyond doing an alias for every number within the possible temperature range).  There might be a hint you can use for numbers, not sure.  On Win10 it gets double-digit numbers correct.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Sunday, July 29, 2018 3:57 PM
    Moderator
  • OK, on Win10 it gets "wind" correct.  I would imagine an alias like "whind" would probably fix it on Win7.

    The only thing I'm not completely sure of is fixing the numbers (beyond doing an alias for every number within the possible temperature range).  There might be a hint you can use for numbers, not sure.  On Win10 it gets double-digit numbers correct.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Yup, how one spells it has a lot to do with what comes out. Its kind of funny to play with. That's when the wind the clock hit me.

    If one wants to get into that depends on what is generating the OP source text etc. Or sorting through the source with a custom substitution table or something. For a well defined thing like weather words it might work? Although there are a lot of words for rain with thunder and lightning I found making my desktop weather bug and they keep finding new ones.

    I was reading it has a time slice it cuts things up into. One could adjust the speed. Not sure what that was now. So I was thinking the slower it is running the pronunciation the more accurate? ie three slices per letter or something. I have not looked for a setting.


    Sunday, July 29, 2018 4:45 PM
  • PS Reed do you know how does it get "wind" correct in win10? Does it use the context around the word? Are you saying that "There is a lot of wind today" comes out "win-duh" and  "Wind the clock today" comes out "whine-duh" ? Is that what you mean?

    Just curious.

    Sunday, July 29, 2018 6:04 PM
  • Here is a code example for anyone wanting to try it.

    Imports System.Speech.Synthesis
    
    Public Class Form5
        Private WithEvents Button1 As New Button With {.Parent = Me, .Location = New Point(150, 200), .Text = "Speak"}
        Private WithEvents TextBox1 As New TextBox With {.Parent = Me, .Location = New Point(20, 10), .Font = New Font("arial", 10),
            .Size = New Size(250, 150), .Multiline = True}
        Private speaker As New SpeechSynthesizer
        Private voice As String = ""
    
        Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'TextBox1.Text = "High Ninety Two Degrees Fairunheight. Winned South at five to ten miles per hour."
            TextBox1.Text = "Please wind the clock today." & vbCrLf & vbCrLf & "The wind is from the west today."
    
            For Each vc As InstalledVoice In speaker.GetInstalledVoices()
                voice = vc.VoiceInfo.Name
                Exit For
            Next
    
            If voice.Trim = "" Then
                MessageBox.Show("No voices found.")
            Else
                speaker.Rate = 0
                speaker.Volume = 100
                speaker.SelectVoice(voice)
            End If
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Try
                speaker.Speak(TextBox1.Text)
            Catch
                Beep()
            End Try
        End Sub
    
    End Class

    Sunday, July 29, 2018 7:58 PM
  • PS Reed do you know how does it get "wind" correct in win10? Does it use the context around the word? Are you saying that "There is a lot of wind today" comes out "win-duh" and  "Wind the clock today" comes out "whine-duh" ? Is that what you mean?

    Just curious.

    Apparently there is a more robust default lexicon in Win10 because:

    "You must wind the clock to keep time."

    ...and...

    "The wind is blowing very hard today."

    ...both use the correct pronunciation of the word "wind" in each sentence.

    So yes, there are apparently some contextual hints in the lexicon.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, July 30, 2018 12:59 PM
    Moderator
  • I did listen in windows 10 and yes it is correct based on context as Reed says.

    It is the microsoft david and zira voices on win 10 (they are also on win 8 not tested) that say wind correctly.

    It appears you can download these voices and add them to win 7 with some effort which I did not do. You must??  get the speech platform update (not sure required)?. Apparently the voices are in the English package and you install the speech version:

    ms speech platform

    https://www.microsoft.com/en-us/download/details.aspx?id=27225


    ms english
    https://www.microsoft.com/en-us/download/details.aspx?id=27224

    https://superuser.com/questions/590779/how-to-install-more-voices-to-windows-speech

    Search for how to install David windows 7 etc.

    I did not try to add the voices when I saw what was required.

    Monday, July 30, 2018 3:52 PM
  • I'm not 100% sure, but I don't think the voice is what is important... that's going to be more about the tone and inflection used.  I'm pretty sure this is all about the lexicon that drives the voice.  You can probably fix the one in Win7 by creating a better lexicon using the documentation I linked above (albeit, with a lot of work deciphering the format and options possible in the XML file). 

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, July 30, 2018 4:15 PM
    Moderator
  • I'm not 100% sure, but I don't think the voice is what is important... that's going to be more about the tone and inflection used.  I'm pretty sure this is all about the lexicon that drives the voice.  You can probably fix the one in Win7 by creating a better lexicon using the documentation I linked above (albeit, with a lot of work deciphering the format and options possible in the XML file). 

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    Oh, I see.

    As noted someone said you need the speech platform version 11 for win 7...  is the lexicon changed with that? I dont know what the lexicon is etc.

    Anyway, the quick answer now seems to be use windows 8 and higher as it works there (spell out letters and numbers and etc)???

    So it depends on OPs requirements I guess.

    :)

    Monday, July 30, 2018 4:26 PM
  • I'm not 100% sure, but I don't think the voice is what is important... that's going to be more about the tone and inflection used.  I'm pretty sure this is all about the lexicon that drives the voice.  You can probably fix the one in Win7 by creating a better lexicon using the documentation I linked above (albeit, with a lot of work deciphering the format and options possible in the XML file). 


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    Oh, I see.

    As noted someone said you need the speech platform version 11 for win 7...  is the lexicon changed with that? I dont know what the lexicon is etc.

    Anyway, the quick answer now seems to be use windows 8 and higher as it works there (spell out letters and numbers and etc)???

    So it depends on OPs requirements I guess.

    :)

    I'm assuming that the later versions of Windows include a stronger lexicon than what was included with Win7.  If you go back up to my first post in this thread, there is an example of a lexicon file (XML) and a link to the standard for writing custom lexicons.  The lexicon is basically the "ruleset" for how words should be pronounced.  It can take a number of different elements from direct pronunciations to replacements to grammatical hints.  It can be a fairly simple document (as in the example I posted for handling the temperature and direction abbreviations) to very complex (as shown in many of the example listed in the linked documentation).

    You can probably add the example XML file I posted to your Win7 solution and then load it using the code I show in Form.Load and get Win7 to say "South" for " S " and Fahrenheit for "F " in the OPs original example sentence. 


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Monday, July 30, 2018 5:56 PM
    Moderator