컴퓨터/파이썬 (Python)

[Python] wav 파일 Speech-to-Text 파이썬 코드

COMKONG 2023. 3. 21. 22:34
반응형
import speech_recognition as sr

r = sr.Recognizer()

text = sr.AudioFile('Source.wav')

with text as source:
    audio = r.record(source)

print("Source:"+r.recognize_google(audio))

 

5분 이상 되는 음원은 오류가 나는 것 같음.

음원을 자르는 파이썬 코드는 아래에 있음.

https://hb2207.tistory.com/54

 

[Python] wav 파일 자르기

import wave # 원하는 시간 단위 (초) start = 1 # 시작 시간, seconds end = 300 # 끝나는 시간, seconds # file to extract the snippet from with wave.open('test.wav', "rb") as infile: # get file data nchannels = infile.getnchannels() sampwidth

hb2207.tistory.com

 

파이썬 실행 후 Print 결과 부분을 복사해서 사용하거나
text 파일로 저장하는 코드를 아래에 추가하면 txt 파일로 추출 가능하다.

회의/미팅 같은 거 하고 내용을 복기 할 때 유용하다. (물론 상대의 동의를 구하고 녹음을 한)

반응형