from services.AudioTokenizerService import get_audio_tokenizer_service | |
from fastapi import APIRouter, Depends, HTTPException, status | |
from fastapi import File, UploadFile | |
from models.audio import AudioFormat, FORMAT_BACKENDS | |
audio_tokenizer_router = APIRouter( | |
prefix="/tokenize", tags=["audio"]) | |
async def tokenize_audio(format: AudioFormat = "wav", file: UploadFile = File(...)): | |
file_obj = await file.read() | |
get_audio_tokenizer_service().tokenize(file_obj, format) | |
return get_audio_tokenizer_service().tokenize(file_obj, format) | |
async def get_supported_formats(): | |
return get_audio_tokenizer_service().get_format_info() | |