add banbanmini backend
This commit is contained in:
28
talkingq-url/services/tts_audio_cleaner.py
Normal file
28
talkingq-url/services/tts_audio_cleaner.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from config import settings
|
||||
import asyncio
|
||||
|
||||
|
||||
class TTSAudioCleaner:
|
||||
|
||||
|
||||
@staticmethod
|
||||
async def prepare_output_directory():
|
||||
|
||||
tts_dir = Path(settings.assets_dir) / "tts_audio"
|
||||
loop = asyncio.get_running_loop()
|
||||
await loop.run_in_executor(None, lambda: os.makedirs(tts_dir, exist_ok=True))
|
||||
return tts_dir
|
||||
|
||||
@staticmethod
|
||||
def generate_filename(device_id: str, session_id: str, sequence_number: int):
|
||||
seq_str = f"{sequence_number:02d}"
|
||||
file_name = f"{device_id}_{session_id}_{seq_str}"
|
||||
output_file_prefix = os.path.join(settings.assets_dir, "tts_audio", file_name)
|
||||
return output_file_prefix
|
||||
|
||||
@staticmethod
|
||||
def generate_audio_url(audio_file_path: str):
|
||||
file_name = os.path.basename(audio_file_path)
|
||||
return f"assets/tts_audio/{file_name}"
|
||||
Reference in New Issue
Block a user