我正在尝试通过 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)