TEST Engineering/자동화 & 유용한도구 Tips
파이썬으로 음성 인식 스크립트 만들기
얍얍폴폴
2023. 9. 4. 10:45
녹음된 음성파일을 읽어서 txt 형태로 변환 하는 스크립트
import speech_recognition as sr
recognizer = sr.Recognizer()
audio_file = '/Users/project/test/audio.wav'
with sr.AudioFile(audio_file) as source:
audio_data = recognizer.record(source)
try:
text = recognizer.recognize_google(audio_data)
print("Transcription:")
print(text)
except sr.UnknownValueError:
print("Google Web Speech API could not understand the audio")
except sr.RequestError as e:
print(f"Could not request results from Google Web Speech API; {e}")
with open("output.txt", "w") as text_file:
text_file.write(text)