Open Amir231123 opened 3 months ago
import speech_recognition as sr
audio_file_path = "path_to_your_file.wav"
recognizer = sr.Recognizer()
with sr.AudioFile(audio_file_path) as source: audio_data = recognizer.record(source)
text = recognizer.recognize_google(audio_data)
print("Transcription:\n", text)
import speech_recognition as sr
Path to your .wav file
audio_file_path = "path_to_your_file.wav"
Initialize recognizer class (for recognizing the speech)
recognizer = sr.Recognizer()
Recognize the speech in the audio file
with sr.AudioFile(audio_file_path) as source: audio_data = recognizer.record(source)
Convert speech to text
Print the transcribed text
print("Transcription:\n", text)