0

I'm trying to Convert Speech to text using speech recognition library. but when I run the Code it shows Value Error About the Audio Type I Tried to change the file format to a lot of audio format like: "PCM, WAV, AIFF, AIFF-C, Mp3, Mp4, FLAC, WebM, wav..." by renaming the file extension. But, it still show the Same Error.

The Error:

ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format

The Code:

import speech_recognition as sr
filename = "hello.mp3"
r = sr.Recognizer()
with sr.AudioFile(filename) as source:
   audio = r.record(source)
   text = r.recognize_google(audio)
print(text)

1 Answer 1

0

I dont think renaming the file extension will help you, you should use a file converter to make sure the audio data is beeing correctly encoded in another format. Try using SoundConverter

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.