Created
June 23, 2024 14:34
-
-
Save hctilg/ed6af1b0940bb3d7758aa372b53badcf to your computer and use it in GitHub Desktop.
Sound to Text (fa-IR)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import speech_recognition as sr | |
from pydub import AudioSegment | |
audio_file = "your_audio_file_path_here.mp3" | |
sound = AudioSegment.from_mp3(audio_file) | |
sound.export("output.wav", format="wav") | |
recognizer = sr.Recognizer() | |
with sr.AudioFile("output.wav") as source: | |
audio_data = recognizer.record(source) | |
text = recognizer.recognize_google(audio_data, language="fa-IR") | |
print(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment