Transcribe-TG / main.py
API-Handler's picture
Upload 18 files
a4ff920 verified
raw
history blame contribute delete
697 Bytes
from fastapi import FastAPI, UploadFile
from vosk_handler import VoskTranscriber
import io
app = FastAPI()
transcriber = VoskTranscriber()
@app.post("/transcribe/")
async def transcribe_audio(audio_file: UploadFile):
try:
# Read file content into memory
content = await audio_file.read()
# Create in-memory file-like object
audio_data = io.BytesIO(content)
# Process the audio
result = transcriber.transcribe_audio(audio_data)
return result
except Exception as e:
return {"success": False, "error": str(e)}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)