使用Google Speech API

用户名

在基于C#的应用程序中实现Google Speech API的代码是什么?我发现可以创建一个音频文件并将其发送到http://slides.html5rocks.com/#speech-input并以文本形式接收。如果您以前尝试过此方法,可以请您说明如何执行此操作或向我提供代码吗?现在被困在这里了一段时间

非常感激。

到目前为止的代码:

    SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
    SpeechSynthesizer dummy = new SpeechSynthesizer();


    public Form1()
    {
        InitializeComponent();


        Choices searching = new Choices("Porsche");
        GrammarBuilder searchService = new GrammarBuilder("Search");

        searchService.Append(searching);


        // Create a Grammar object from the GrammarBuilder and load it to the  recognizer.
        Grammar googleGrammar = new Grammar(searchService); ;
        rec.RequestRecognizerUpdate();
        rec.LoadGrammar(googleGrammar);

        // Add a handler for the speech recognized event.
        rec.SpeechRecognized +=
          new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized);

        // Configure the input to the speech recognizer.
        rec.SetInputToDefaultAudioDevice();

        // Start asynchronous, continuous speech recognition.
        rec.RecognizeAsync(RecognizeMode.Multiple);
    }




    private void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {

        try
        {
            FileStream FS_Audiofile = new FileStream("temp.flac", FileMode.Open, FileAccess.Read);
            BinaryReader BR_Audiofile = new BinaryReader(FS_Audiofile);
            byte[] BA_AudioFile = BR_Audiofile.ReadBytes((Int32)FS_Audiofile.Length);
            FS_Audiofile.Close();
            BR_Audiofile.Close();

            HttpWebRequest _HWR_SpeechToText = null;

            _HWR_SpeechToText = (HttpWebRequest)WebRequest.Create("http://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=de-DE&maxresults=1&pfilter=0");

            _HWR_SpeechToText.Method = "POST";
            _HWR_SpeechToText.ContentType = "audio/x-flac; rate=44100";
            _HWR_SpeechToText.ContentLength = BA_AudioFile.Length;
            _HWR_SpeechToText.GetRequestStream().Write(BA_AudioFile, 0, BA_AudioFile.Length);

            HttpWebResponse HWR_Response = (HttpWebResponse)_HWR_SpeechToText.GetResponse();
            if (HWR_Response.StatusCode == HttpStatusCode.OK)
            {
                StreamReader SR_Response = new StreamReader(HWR_Response.GetResponseStream());
                textBox1.Text = SR_Response.ToString();

            }

        }
        catch (Exception ex)
        {

        }  
    }

这不会从Google返回任何值。

罗伯特·罗恩特里

只要发送的文件不是太长,以下内容就会在curl中起作用……不到5秒。

curl -X POST -H“内容类型:音频/ x-flac;速率= 16000” \ -T seg_1.flac“ https://www.google.com/speech-api/v1/recognize?\ xjerr = 1&client = speech2text&maxresults = 1&lang = zh-CN&key = ... 48593“

{“状态”:0,“ id”:“”,“假设”:[{“话语”:“现在是最喜欢的消遣”,“信心”:0.95148802}]}

因此,编码为speechX或flac

在记录中包含采样率的参数

包括你的钥匙

保持文件持续时间短(在访问API之前,您必须先拆分文件)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Google Speech API流

来自分类Dev

验证和使用 Google Cloud Speech API

来自分类Dev

还支持Google Speech API吗?

来自分类Dev

新的 Google Speech API 的问题

来自分类Dev

尝试使用Google Cloud Speech API时抛出403

来自分类Dev

HTML页面上的Google Cloud Speech API

来自分类Dev

使用Web Speech API检测已知单词

来自分类Dev

使用 Web Speech API 的 Angular 4

来自分类Dev

需要一个简单的.NET的Google Speech API示例

来自分类Dev

如何在Python程序中嵌入Google Speech to Text API?

来自分类Dev

Flutter:Google Speech-To-Text API始终返回null

来自分类Dev

Google Speech-to-Text API因多重处理python失败

来自分类Dev

Google Speech Api v1无法正常工作吗?

来自分类Dev

点击播放网站上的Google Text to Speech Api

来自分类Dev

Google Cloud Text To Speech REST API 身份验证

来自分类Dev

是否可以将Google的Web Speech API与非Web应用程序结合使用?

来自分类Dev

尝试使用Google Cloud Text-to-Speech API时无效的JWT

来自分类Dev

通过Web Speech API使用SSML的正确方法

来自分类Dev

在Web Speech API中使用SSML的正确方法

来自分类Dev

在网络应用中使用Dialogflow和Google Cloud Speech API构建自己的对话语音AI

来自分类Dev

Web Speech API可以与Web Audio API一起使用吗?

来自分类Dev

使用pydub导出Google Speech的音频

来自分类Dev

Kaldi是否会返回类似于Google Speech-To-Text API的任何识别置信度参数?

来自分类Dev

如何在Google Speech-to-Text API中进行多个streamingRecognize请求?

来自分类Dev

嵌套数组PHP作为对Google Speech API的响应,如何提取元素?

来自分类Dev

Google Speech API:在此服务器上找不到请求的 URL

来自分类Dev

如何在 Google Speech API 中显示词级置信度分数

来自分类Dev

不能使用curl来使用Google Cloud Speech API来识别10到15分钟内的文件吗?

来自分类Dev

使用 Firebase Auth 对其进行身份验证后,如何在最终用户 c# 应用程序中安全地使用 Google Speech API?

Related 相关文章

  1. 1

    Google Speech API流

  2. 2

    验证和使用 Google Cloud Speech API

  3. 3

    还支持Google Speech API吗?

  4. 4

    新的 Google Speech API 的问题

  5. 5

    尝试使用Google Cloud Speech API时抛出403

  6. 6

    HTML页面上的Google Cloud Speech API

  7. 7

    使用Web Speech API检测已知单词

  8. 8

    使用 Web Speech API 的 Angular 4

  9. 9

    需要一个简单的.NET的Google Speech API示例

  10. 10

    如何在Python程序中嵌入Google Speech to Text API?

  11. 11

    Flutter:Google Speech-To-Text API始终返回null

  12. 12

    Google Speech-to-Text API因多重处理python失败

  13. 13

    Google Speech Api v1无法正常工作吗?

  14. 14

    点击播放网站上的Google Text to Speech Api

  15. 15

    Google Cloud Text To Speech REST API 身份验证

  16. 16

    是否可以将Google的Web Speech API与非Web应用程序结合使用?

  17. 17

    尝试使用Google Cloud Text-to-Speech API时无效的JWT

  18. 18

    通过Web Speech API使用SSML的正确方法

  19. 19

    在Web Speech API中使用SSML的正确方法

  20. 20

    在网络应用中使用Dialogflow和Google Cloud Speech API构建自己的对话语音AI

  21. 21

    Web Speech API可以与Web Audio API一起使用吗?

  22. 22

    使用pydub导出Google Speech的音频

  23. 23

    Kaldi是否会返回类似于Google Speech-To-Text API的任何识别置信度参数?

  24. 24

    如何在Google Speech-to-Text API中进行多个streamingRecognize请求?

  25. 25

    嵌套数组PHP作为对Google Speech API的响应,如何提取元素?

  26. 26

    Google Speech API:在此服务器上找不到请求的 URL

  27. 27

    如何在 Google Speech API 中显示词级置信度分数

  28. 28

    不能使用curl来使用Google Cloud Speech API来识别10到15分钟内的文件吗?

  29. 29

    使用 Firebase Auth 对其进行身份验证后,如何在最终用户 c# 应用程序中安全地使用 Google Speech API?

热门标签

归档