How to get speech recognition to detect SAPI empha

2019-08-29 09:19发布

问题:

It is possible to extract the default phonemes for a given word via SAPI by:

  1. Voice word with text-to-speech and store output in a .wav
  2. Use the .wav as input for speech recognition
  3. Upon recognition of the word extract the phonemes from the recognized phrase elements

However I have not been able to capture (if available) emphasis markers ("1" and "2" per the American English Phoneme Table). Is there a way to do this?

EDIT: Here is what I've attempted so far (not pretty, but functional). Sadly it looks like the SpeechVisemeFeature always shows "SVF_None," even when I manually add emphasis to a word via SAPI Speech Dictionary modification. Does anyone know why this is?

using System;
using System.Threading;
using SpeechLib;
using System.Windows.Forms;

namespace PhoneEmphasis
{
    class Program
    {
        static string myWord = "hello";
        static SpPhoneConverter c = new SpPhoneConverter();
        static Thread t = null;

        static void Main(string[] args)
        {
            c.LanguageId = 1033;
            t = new Thread(test);
            t.Start();
            t.Join();
            Console.WriteLine("done");
            Console.ReadLine();
        }

        private static void test()
        {
            SpVoice v = new SpVoice();
            //v.EventInterests = SpeechVoiceEvents.;
            v.Phoneme += new _ISpeechVoiceEvents_PhonemeEventHandler(Phoneme_Handler);
            v.EndStream += new _ISpeechVoiceEvents_EndStreamEventHandler(EndStream_Handler);
            v.Speak(myWord, SpeechVoiceSpeakFlags.SVSFlagsAsync);
            Application.Run();
        }

        private static void Phoneme_Handler(int StreamNumber, object StreamPosition, int Duration, short NextPhoneId, SpeechVisemeFeature Feature, short CurrentPhoneId)
        {
            Console.WriteLine("Phoneme = " + c.IdToPhone(CurrentPhoneId).ToString() + " , VisemeFeature = " + Feature.ToString());
        }

        private static void EndStream_Handler(int StreamNumber, object StreamPosition)
        {
            Console.WriteLine("end stream!");
            t.Abort();
        }
    }
}