小编Ale*_*sal的帖子

使用Python将云语音API的结果导出到JSON文件

我正在尝试通过 Google Speech API 将音频文件转换为印度语言的文本。API 返回类型为“google.cloud.speech_v1.types.SpeechRecognitionAlternative”的对象。我正在尝试将结果导出到 .json 文件。我对python很陌生。这是我在 python 中做的第一个项目。

    import io
    import os
    import pickle

    # Imports the Google Cloud client library
    from google.cloud
    import speech
    from google.cloud.speech
    import enums
    from google.cloud.speech
    import types

    client = speech.SpeechClient()

    audio = types.RecognitionAudio(uri = "gs://storage-staples-canada/client-data/TapTapTap.wav")
    config = types.RecognitionConfig(
      encoding = enums.RecognitionConfig.AudioEncoding.LINEAR16,
      sample_rate_hertz = 16000,
      language_code = 'hi-IN',
      enable_word_time_offsets = True,
      speech_contexts = [speech.types.SpeechContext(phrases = ['?? ???? ???', '??? ??? ?????', '?? ??? ????? ???? ?????', '???? ??? ??? ????? ??? ??? ???? …
Run Code Online (Sandbox Code Playgroud)

python json dictionary google-speech-api

5
推荐指数
2
解决办法
2155
查看次数

标签 统计

dictionary ×1

google-speech-api ×1

json ×1

python ×1