Update app.py
Browse files
app.py
CHANGED
|
@@ -676,6 +676,7 @@ class GroqRequest(BaseModel):
|
|
| 676 |
url: str
|
| 677 |
language: Optional[str] = None
|
| 678 |
temperature: Optional[float] = 0.4
|
|
|
|
| 679 |
|
| 680 |
def groq_json_to_srt(data):
|
| 681 |
"""Converte resposta verbose_json do Whisper/Groq para SRT"""
|
|
@@ -707,7 +708,7 @@ def groq_json_to_srt(data):
|
|
| 707 |
|
| 708 |
from srt_utils import apply_netflix_style_filter, process_audio_for_transcription
|
| 709 |
|
| 710 |
-
async def get_groq_srt_base(url: str, language: Optional[str] = None, temperature: Optional[float] = 0.4):
|
| 711 |
"""
|
| 712 |
Helper para gerar SRT base usando Groq (dando suporte a filtro Netflix).
|
| 713 |
Retorna (srt_filtered, srt_word_level, processed_audio_url)
|
|
@@ -745,9 +746,9 @@ async def get_groq_srt_base(url: str, language: Optional[str] = None, temperatur
|
|
| 745 |
|
| 746 |
try:
|
| 747 |
# 2. Pré-processar (Remover ruído, filtrar voz, etc)
|
| 748 |
-
print(f"🔊 [Groq] Pré-processando áudio (
|
| 749 |
# O process_audio cria um arquivo novo com .processed.mp3
|
| 750 |
-
processed_file_path = process_audio_for_transcription(filepath)
|
| 751 |
|
| 752 |
# Se processou, o caminho mudou. Vamos ver.
|
| 753 |
if processed_file_path != filepath:
|
|
@@ -843,7 +844,8 @@ async def generate_subtitle_groq(request: GroqRequest):
|
|
| 843 |
srt_filtered, srt_word, processed_audio_url = await get_groq_srt_base(
|
| 844 |
url=request.url,
|
| 845 |
language=request.language,
|
| 846 |
-
temperature=request.temperature
|
|
|
|
| 847 |
)
|
| 848 |
|
| 849 |
return JSONResponse(content={
|
|
|
|
| 676 |
url: str
|
| 677 |
language: Optional[str] = None
|
| 678 |
temperature: Optional[float] = 0.4
|
| 679 |
+
has_bg_music: Optional[bool] = False # Default to False for speed/resources
|
| 680 |
|
| 681 |
def groq_json_to_srt(data):
|
| 682 |
"""Converte resposta verbose_json do Whisper/Groq para SRT"""
|
|
|
|
| 708 |
|
| 709 |
from srt_utils import apply_netflix_style_filter, process_audio_for_transcription
|
| 710 |
|
| 711 |
+
async def get_groq_srt_base(url: str, language: Optional[str] = None, temperature: Optional[float] = 0.4, has_bg_music: bool = False):
|
| 712 |
"""
|
| 713 |
Helper para gerar SRT base usando Groq (dando suporte a filtro Netflix).
|
| 714 |
Retorna (srt_filtered, srt_word_level, processed_audio_url)
|
|
|
|
| 746 |
|
| 747 |
try:
|
| 748 |
# 2. Pré-processar (Remover ruído, filtrar voz, etc)
|
| 749 |
+
print(f"🔊 [Groq] Pré-processando áudio (has_bg_music={has_bg_music})...")
|
| 750 |
# O process_audio cria um arquivo novo com .processed.mp3
|
| 751 |
+
processed_file_path = process_audio_for_transcription(filepath, has_bg_music=has_bg_music)
|
| 752 |
|
| 753 |
# Se processou, o caminho mudou. Vamos ver.
|
| 754 |
if processed_file_path != filepath:
|
|
|
|
| 844 |
srt_filtered, srt_word, processed_audio_url = await get_groq_srt_base(
|
| 845 |
url=request.url,
|
| 846 |
language=request.language,
|
| 847 |
+
temperature=request.temperature,
|
| 848 |
+
has_bg_music=request.has_bg_music
|
| 849 |
)
|
| 850 |
|
| 851 |
return JSONResponse(content={
|