0

I am using the Google Cloud Platform to convert some audio into text files through the Google Speech-to-Text API. I keep getting the error: google.api_core.exceptions.InvalidArgument: 400 Must use single channel (mono) audio, but WAV header indicates 1 channels.

Here is my code:

config_wave_enhanced = speech.types.RecognitionConfig(
    #sample_rate_hertz=44100,
    encoding = 'LINEAR16',
    enable_automatic_punctuation=True,
    language_code='en-US',
    #use_enhanched=True,
    model='video',
    enable_separate_recognition_per_channel = True,
    audio_channel_count = 2
    )

operation = speech_client.long_running_recognize(
    config=config_wave_enhanced,
    audio=long_audi_wave
    )

response = str(operation.result(timeout=90))

Can anyone help me solve this error? I'm going crazy here.

Mark
  • 1

2 Answers2

0

Setting audio_channel_count = 1 might help.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
0

Convert your audio to 1-channel. You can do this using command line ffmpeg -i stereo.wav -ac 1 mono.wav. Also set audio_channel_count = 1 as Christian Adib mentioned.