如何获得语音识别以检测SAPI重点标记?

时间:2019-05-21 19:15:31

标签: c# .net speech-recognition sapi phoneme

可以通过以下方式通过SAPI提取给定单词的默认音素:

  1. 带有语音合成功能的语音单词,并将输出存储在.wav中
  2. 使用.wav作为语音识别的输入
  3. 识别单词后,从中提取音素 公认的短语元素

但是,我无法捕获(如果可用)重点标记(American English Phoneme Table中的“ 1”和“ 2”)。有办法吗?

编辑:这是我到目前为止已经尝试过的(虽然不漂亮,但是很实用)。可悲的是,即使我手动给一个单词加了重音,SpeechVisemeFeature也总是显示“ SVF_None”。通过SAPI语音词典修改。 有人知道这是为什么吗?

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

0 个答案:

没有答案