繁体   English   中英

Windows 8.1 Bing语音识别控制 - 无效的媒体类型

[英]Windows 8.1 Bing Speech Recognition Control - Invalid media type

我们正在开发Windows 8.1环境中的应用程序。 我想实现Bing语音识别控件。 见这个

图标出现了,我已经像这个解决方案一样实现了代码。

这就是我在代码背后所做的事情

//When page is loaded
private void ProblemenTest_Loaded(object sender, RoutedEventArgs e)
{
    //Bing speech recognition initialiseren
    var credentials = new SpeechAuthorizationParameters();
    credentials.ClientId = "myemail";
    credentials.ClientSecret = "mypass";

    // Initialize the speech recognizer.
    SR = new SpeechRecognizer("en-US", credentials);

    // Add speech recognition event handlers.
    SR.AudioLevelChanged += SR_AudioLevelChanged;
    SR.RecognizerResultReceived += SR_RecognizerResultReceived;
}

//Microphone button clicked event
private async void BtnMicrofoon_Click(object sender, RoutedEventArgs e)
{
    var result = await SR.RecognizeSpeechToTextAsync(); //Error here
    txtProblem.Text = result.Text;
}

//When speech recognition has finished
void SR_RecognizerResultReceived(SpeechRecognizer sender,
    SpeechRecognitionResultReceivedEventArgs args)
{
    if (args.Text == null) return;
    txtProblem.Text = args.Text;
}

//When audioleven changed
void SR_AudioLevelChanged(SpeechRecognizer sender,
    SpeechRecognitionAudioLevelChangedEventArgs args)
{
    var v = args.AudioLevel;
    if (v > 0) VolumeMeter.Opacity = v / 50;
    else VolumeMeter.Opacity = Math.Abs((v - 50) / 100);
}

当我单击按钮时,我收到一个错误,抱怨媒体类型无效。

错误信息

我应该在哪里查找此错误的来源?

出现了同样的问题并且遇到了来自微软员工Johannes Kebeck http://jkebeck.wordpress.com/的一个伟大的地理空间博客,他在2013年11月16日的帖子中提到必须在你的包装中设置麦克风的设备功能.appxmanifest(我已经想到了)但关键是你还必须允许三个DLL可激活。

要执行此操作,您只需手动编辑文件(右键单击,打开方式...,选择XML文本编辑器),然后添加以下功能:

<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
  <InProcessServer>
    <Path>Microsoft.Speech.VoiceService.MSSRAudio.dll</Path>
    <ActivatableClass ActivatableClas-sId="Microsoft.Speech.VoiceService.MSSRAudio.Encoder" ThreadingModel="both" />
  </InProcessServer>
</Extension>
<Extension Category="windows.activatableClass.proxyStub">
  <ProxyStub ClassId="5807FC3A-A0AB-48B4-BBA1-BA00BE56C3BD">
    <Path>Microsoft.Speech.VoiceService.MSSRAudio.dll</Path>
    <Interface Name="IEncodingSettings" InterfaceId="C97C75EE-A76A-480E-9817-D57D3655231E" />
  </ProxyStub>
</Extension>
<Extension Category="windows.activatableClass.proxyStub">
  <ProxyStub ClassId="F1D258E4-9D97-4BA4-AEEA-50A8B74049DF">
    <Path>Microsoft.Speech.VoiceService.Audio.dll</Path>
    <Interface Name="ISpeechVolumeEvent" InterfaceId="946379E8-A397-46B6-B9C4-FBB253EFF6AE" />
    <Interface Name="ISpeechStatusEvent" InterfaceId="FB0767C6-7FAA-4E5E-AC95-A3C0C4D72720" />
  </ProxyStub>
</Extension>
</Extensions>

保存,重新编译,您的语音识别现在可以正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM