可以通过以下方式通过SAPI提取给定单词的默认音素:
但是,我无法捕获(如果可用)重点标记(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();
}
}
}