Я пытаюсь использовать пример кода со страницы Google для расшифровки 30-минутного WAV-файла.Я немного изменил исходный код, и он ниже:
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'C:\\Users\\louie\\Desktop\\PSC.json'
gcs_uri = os.path.join('C:\\Users\\louie\\Desktop','Untitled1.wav')
client = speech.SpeechClient()
audio = types.RecognitionAudio(uri=gcs_uri)
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=44100,
language_code='en-US')
operation = client.long_running_recognize(config, audio)
print('Waiting for operation to complete...')
response = operation.result(timeout=90)
# 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))
Когда я его запустил, я получил ошибку 400 Request contains an invalid argument
Я почти уверен, что мои предварительные настройки верны, так как код для короткой транскрипции работаетдля меня.Может ли кто-нибудь помочь мне в этом вопросе?Спасибо!
Редактировать: Я думаю, что эта проблема связана с неправильным форматом gcs_uri.Есть ли способ расшифровки больших аудиофайлов без загрузки их в облачное хранилище Google?