Author Topic: train profiles to dictionary  (Read 1231 times)

Squeeze

  • Newbie
  • *
  • Posts: 9
train profiles to dictionary
« on: November 09, 2017, 06:40:35 pm »
hi there! the standard feature of adding and recording words to the dictionary of the MS Speech Engine is too complicated. i wish Voice Attack had a plugin which lets you record all phrases of a profile and add them to the dictionary. Is this possible to implement?
« Last Edit: November 09, 2017, 06:45:05 pm by Squeeze »

Exergist

  • Sr. Member
  • ****
  • Posts: 325
  • Can you dig it?
Re: train profiles to dictionary
« Reply #1 on: November 10, 2017, 08:28:25 am »
I actually have a C# inline function that leverages the MS Speech API that allows for the adding and removal of information to the user's dictionary (lexicon). I need to do some more testing but I'll post it when I'm done.

Though maybe Gary has something else up his sleeve?

Squeeze

  • Newbie
  • *
  • Posts: 9
Re: train profiles to dictionary
« Reply #2 on: November 10, 2017, 12:25:18 pm »
Thanks for investigating, i think it would definitely raise the recognition rate of Voice Attack.

Squeeze

  • Newbie
  • *
  • Posts: 9
Re: train profiles to dictionary
« Reply #3 on: November 16, 2017, 04:40:56 pm »
i know that it is possible to add words to the dictionary through API but i don't know if it's possible to record a phrase belonging to the word without the MS dictionary tool. I thought of writing a tool which reads VA's profiles and automatically inserts the word in the dictionary tool, simulate some button presses to get to the record button. After recording you need to click once to complete the registration of the new word. After that you press a button in my tool which iniates the next word. This method may not be ideally but would fasten up things a little bit.
I definetely would prefer another method if it's possible to record words through API......

Exergist

  • Sr. Member
  • ****
  • Posts: 325
  • Can you dig it?
Re: train profiles to dictionary
« Reply #4 on: November 17, 2017, 02:09:28 pm »
Well I think I've got it! This is pretty outstanding so I'm going to be brief just to share the bare bones functionality. Hopefully I'll have more time next week to better expand upon this in the Inline Functions thread.

In a nutshell you have to leverage the Microsoft Speech API (SAPI) 5.4 (or maybe newer versions work as well?). You'll need to reference Interop.SpeechLib.dll (attached), and using a C# inline function you can add and remove words from the user lexicon (dictionary).

Here is the base code from Visual Studio to remove a word:
Code: [Select]
using System;
using SpeechLib;

SpLexicon lex = new SpLexicon();
int langid = new System.Globalization.CultureInfo("en-US").LCID;
lex.RemovePronunciation("poticharoo", langid, SpeechPartOfSpeech.SPSNoun, "p ow t iy ch ax r uw");

Here is the base code to add a word:
Code: [Select]
using System;
using SpeechLib;

SpLexicon lex = new SpLexicon();
int langid = new System.Globalization.CultureInfo("en-US").LCID;
lex.AddPronunciation("poticharoo", langid, SpeechPartOfSpeech.SPSNoun, "p ow t iy ch ax r uw");

The odd string of characters at the end of the function are the symbolic phones that the system interprets. I've compiled some information about this and attached it as well.

I've only done a bit of testing but trying to get Windows Speech Recognition (not VoiceAttack) to recognize "poticharoo" by default has terrible results. VoiceAttack also does not know what to do with it (expected, since VA leverages WSR).

However by simply using the above code to add the word it becomes recognized by both applications. Note that I did not provide any recordings of me saying "poticharoo," this is all handled just through this C# code. After adding the word you can open the WSR dictionary and it should be listed. To top it off, VoiceAttack TTS also pronounces the word correctly once you add it this way!

Give it a try! More details (and probably some reviewing with Gary) to follow :)

Squeeze

  • Newbie
  • *
  • Posts: 9
Re: train profiles to dictionary
« Reply #5 on: November 18, 2017, 08:52:52 am »
very nice, Exergist. I'm not an expert in Windows Speech Recognition and first i thought Windows would save all the recorded phrases as a wave file somewhere. But what i understand from it, it just translates the spoken words in a phonetic formular. Does the library also support the conversion from audio files to the phonetic form? As i started to write my mentioned application i will have a closer look at the DLL, too.

Squeeze

  • Newbie
  • *
  • Posts: 9
Re: train profiles to dictionary
« Reply #6 on: November 21, 2017, 04:50:35 am »
there are functions in SAPI to handle audio streams so i think you could make a plugin for VA that replaces the Dictionary Tool from Microsoft. I hope you will implement it in future Voice Attack versions. Thanks!