How to get speech recognition to detect SAPI emphasis markers?

天大地大妈咪最大 提交于 2019-12-11 14:59:52

问题


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();
        }
    }
}

来源:https://stackoverflow.com/questions/56245050/how-to-get-speech-recognition-to-detect-sapi-emphasis-markers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!