minimo reconocimiento de voz

This commit is contained in:
2025-06-17 08:48:55 -03:00
commit 36fe9f603e
79 changed files with 7662 additions and 0 deletions

View File

@ -0,0 +1,23 @@
from fastapi import FastAPI, WebSocket
from RealtimeSTT.audio_recorder import AudioToTextRecorder
import numpy as np
app = FastAPI()
recorder = AudioToTextRecorder(
model="tiny",
device="cuda",
compute_type="float16",
use_microphone=False,
)
@app.websocket("/ws/transcribe")
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
while True:
data = await websocket.receive_bytes()
# Convierte los bytes a numpy array (ajusta según tu formato)
audio = np.frombuffer(data, dtype=np.float32)
recorder.feed_audio(audio)
text = recorder.text()
await websocket.send_text(text)