File size: 738 Bytes
b46f992
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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"])


@audio_tokenizer_router.post("/{format}")
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)


@audio_tokenizer_router.get("/supported_formats")
async def get_supported_formats():
    return get_audio_tokenizer_service().get_format_info()