-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb1131b
commit edd1241
Showing
6 changed files
with
280 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
|
||
__pycache__ | ||
.cache | ||
*.pt | ||
*.model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from pydantic import BaseModel | ||
from enum import Enum | ||
|
||
class AudioFormat(str, Enum): | ||
WAV = "wav" # Supported by both backends | ||
MP3 = "mp3" # Supported by ffmpeg | ||
FLAC = "flac" # Supported by both | ||
AAC = "aac" # Supported by ffmpeg | ||
OGG = "ogg" # Supported by ffmpeg | ||
OPUS = "opus" # Supported by ffmpeg | ||
PCM = "pcm" # Raw PCM data | ||
|
||
# Format to backend mapping | ||
FORMAT_BACKENDS = { | ||
AudioFormat.WAV: ["soundfile", "ffmpeg"], | ||
AudioFormat.MP3: ["ffmpeg"], | ||
AudioFormat.FLAC: ["soundfile", "ffmpeg"], | ||
AudioFormat.AAC: ["ffmpeg"], | ||
AudioFormat.OGG: ["ffmpeg"], | ||
AudioFormat.OPUS: ["ffmpeg"], | ||
AudioFormat.PCM: ["soundfile"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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() |
Oops, something went wrong.