【问题标题】:Google Cloud Speech API: how to get the full text transcription of audios longer than 1 minute?Google Cloud Speech API:如何获取超过 1 分钟的音频全文转录?
【发布时间】:2018-09-20 14:13:40
【问题描述】:

我使用 Google Cloud Speech API (longrunningrecognize) 成功获得了 5 分钟长音频的转录和替代品,但我没有获得这 5 分钟的全文,只是一个小转录,如下所示:

{
  "name": "2340863807845687922",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
    "progressPercent": 100,
    "startTime": "2018-09-20T13:25:57.948053Z",
    "lastUpdateTime": "2018-09-20T13:28:18.406147Z"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse",
    "results": [
      {
        "alternatives": [
          {
            "transcript": "I am recording it. I think",
            "confidence": 0.9223639
          }
        ]
      },
      {
        "alternatives": [
          {
            "transcript": "these techniques properly stated",
            "confidence": 0.9190353
          }
        ]
      }
    ]
  }
}

如何获取转录生成的全文?

【问题讨论】:

    标签: speech-recognition speech-to-text google-speech-api


    【解决方案1】:

    Google Speech API 使用起来非常痛苦。除了无法翻译长文件外,他们还会随机跳过转录中的大块音频。可能的解决方案是:

    1. 使用语音活动检测和分块分割音频 分别转录每个块
    2. 使用更合理的服务,如 Speechmatics,他们会以更高的准确度毫无问题地处理大文件
    3. 使用 Kaldi 等开源语音识别器。

    【讨论】:

      【解决方案2】:

      我成功解决了这个问题。我必须用 ffmpeg 正确转换文件:

      $ ffmpeg -i /home/user/audio_test.wav -ac 1 -ab 8k audio_test2.wav
      

      *** 删除静音:

      sox audio_test2.wav audio_no_silence4.wav silence -l 1 0.1 1% -1 2.0 1%
      

      并修复我的 sync-request.json:

      {"config": {
            "encoding":"MULAW",
            "sampleRateHertz": 8000,
            "languageCode": "pt-BR",
            "enableWordTimeOffsets": false,
          "enableAutomaticPunctuation": false,
       "enableSpeakerDiarization": true,
          "useEnhanced": true,
      `enter code here`"diarizationSpeakerCount":2,
       "audioChannelCount": 1},
        "audio": {
            "uri":"gs://storage/audio_no_silence4.wav"
        }
      }
      

      然后运行curl。它现在运行良好。

      【讨论】:

        【解决方案3】:

        Google Cloud Speech-to-Text 提供了非常准确的结果。对于一些长音频,它提供了分解成块的成绩单作为您观察到的一系列替代方案。我所做的是在我的识别配置中设置 MaxAlternatives = 1,然后连接替代数组以获得完整的成绩单。下面给出了我在 c# 中使用 Google.Cloud.Speech.V1 的识别配置

        var config = new RecognitionConfig()
        
        
        {
            Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
            //SampleRateHertz = 16000,
            LanguageCode = "en",
            EnableWordTimeOffsets = true,
            MaxAlternatives = 1
         };
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-11-18
          相关资源
          最近更新 更多