Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 谷歌云语音到文本API-无限等待_Python_Google App Engine_Google Cloud Platform_Google Speech Api - Fatal编程技术网

Python 谷歌云语音到文本API-无限等待

Python 谷歌云语音到文本API-无限等待,python,google-app-engine,google-cloud-platform,google-speech-api,Python,Google App Engine,Google Cloud Platform,Google Speech Api,我正在尝试使用谷歌云语音到文本API 我将mp3音频文件格式转换为API文档中所理解的.raw格式,并上传到bucket storage 这是我的密码: def transcribe_gcs(gcs_uri): """Asynchronously transcribes the audio file specified by the gcs_uri.""" from google.cloud import speech from google.cloud.speech i

我正在尝试使用谷歌云语音到文本API

我将mp3音频文件格式转换为API文档中所理解的.raw格式,并上传到bucket storage

这是我的密码:

def transcribe_gcs(gcs_uri):
    """Asynchronously transcribes the audio file specified by the gcs_uri."""
    from google.cloud import speech
    from google.cloud.speech import enums
    from google.cloud.speech import types
    client = speech.SpeechClient()

    audio = types.RecognitionAudio(uri=gcs_uri)
    config = types.RecognitionConfig(
        encoding=enums.RecognitionConfig.AudioEncoding.FLAC,
        sample_rate_hertz=16000,
        language_code='en-US')

    operation = client.long_running_recognize(config, audio)

    print('Waiting for operation to complete...')
    response = operation.result()

    # Each result is for a consecutive portion of the audio. Iterate through
    # them to get the transcripts for the entire audio file.
    for result in response.results:
        # The first alternative is the most likely one for this portion.
        print(u'Transcript: {}'.format(result.alternatives[0].transcript))
        print('Confidence: {}'.format(result.alternatives[0].confidence))

transcribe_gcs("gs://cloudh3-200314.appspot.com/cs.raw")

我做错了什么?

我遇到了类似的问题,这与可接受的格式有关。即使您可能已转换为原始格式,但格式仍可能有问题,如果无法读取文件,它将无法提供输出

我最近处理了一个56分钟的音频,用了17分钟,所以你应该知道它应该有多长时间

使用sox处理您的文件,我找到了使用以下命令工作的转换参数-

sox basefile.mp3 -r 16000 -c 1 newfile.flac

那么错误消息是什么呢?问题是等待永远不会结束。您是否可以尝试直接使用同一文件执行相同的操作,然后检查该操作如何运行。绕过图书馆将澄清问题的真正所在。