Код: Выделить всё
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)
Код: Выделить всё
Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.79k/2.79k [00:00
Подробнее здесь: [url]https://stackoverflow.com/questions/73659692/speech-to-text-with-mic-and-hugging-face-transformers-getting-empty-results[/url]