21 lines
831 B
Python
21 lines
831 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from backend.app.services.markdown_builder import title_from_path
|
|
from backend.app.services.processors.base import ProcessedContent
|
|
from backend.app.services.providers.deepgram_client import DeepgramClient
|
|
|
|
|
|
class AudioProcessor:
|
|
def process(self, path: Path) -> ProcessedContent:
|
|
client = DeepgramClient()
|
|
data = client.transcribe_file(path)
|
|
transcript, confidence = client.transcript_from_response(data)
|
|
confidence_line = f"\n\n_Confianza estimada: {confidence * 100:.1f}%_" if isinstance(confidence, (int, float)) else ""
|
|
return ProcessedContent(
|
|
title=f"Transcripcion {title_from_path(path)}",
|
|
body=f"## Transcripcion\n\n{transcript}{confidence_line}",
|
|
processor="deepgram",
|
|
)
|