Code: Select all
import speech_recognition as sr
from transformers import pipeline
import numpy as np
model = pipeline(model="facebook/wav2vec2-base-960h")
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
#convert audio buffer to numpy array
data = np.frombuffer(audio.get_raw_data())
output = model(data)
print(output)
Code: Select all
Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.79k/2.79k [00:00
Mobile version