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)
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