使用Python進行語音辨識(聲音轉文字)

安裝套件

pip install SpeechRecognition

使用:

import speech_recognition as sr
r = sr.Recognizer() #預設辨識英文
with sr.WavFile("XXXXX.wav") as source: #讀取wav檔
audio = r.record(source)
try:
print("Transcription: " + r.recognize_google(audio,language="zh-TW"))
#使用Google的服務
except LookupError:
print("Could not understand audio")

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store