bred

Generation

generate functionTue, 17 Jan 2023

lấy một file audio rồi dịch thành chữ

import speech_recognition as sr def speech_to_text(path): r = sr.Recognizer() with sr.AudioFile(path) as source: audio = r.record(source) try: return r.recognize_google(audio) except sr.UnknownValueError: print("Google Speech Recognition could not understand audio") except sr.RequestError as e: print("Could not request results from Google Speech Recognition service; {0}".format(e))

Questions about programming?Chat with your personal AI assistant