Spaces:
Paused
Paused
Commit ·
098d1fb
1
Parent(s): 09459a8
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ import stat
|
|
| 11 |
import uuid
|
| 12 |
import subprocess
|
| 13 |
|
| 14 |
-
print(os.getcwd())
|
| 15 |
ZipFile("ffmpeg.zip").extractall()
|
| 16 |
st = os.stat('ffmpeg')
|
| 17 |
os.chmod('ffmpeg', st.st_mode | stat.S_IEXEC)
|
|
@@ -26,6 +25,7 @@ whisper_model = WhisperModel("large-v2", device="cuda", compute_type="float16")
|
|
| 26 |
|
| 27 |
|
| 28 |
def process_video(Video, target_language):
|
|
|
|
| 29 |
print("Iniciando process_video")
|
| 30 |
common_uuid = uuid.uuid4()
|
| 31 |
print("Checking FFmpeg availability...")
|
|
@@ -39,7 +39,7 @@ def process_video(Video, target_language):
|
|
| 39 |
print("Iniciando transcrição com Whisper")
|
| 40 |
segments, _ = whisper_model.transcribe(audio_file, beam_size=5)
|
| 41 |
segments = list(segments)
|
| 42 |
-
transcript_file = f"{common_uuid}.srt"
|
| 43 |
|
| 44 |
# Create a list to hold the translated lines.
|
| 45 |
translated_lines = []
|
|
@@ -93,9 +93,9 @@ def process_video(Video, target_language):
|
|
| 93 |
print(f"{transcript_file} exists.")
|
| 94 |
else:
|
| 95 |
print(f"{transcript_file} does not exist.")
|
| 96 |
-
transcript_file_abs_path = os.path.abspath(transcript_file)
|
| 97 |
try:
|
| 98 |
-
result = subprocess.run(["ffmpeg", "-i", Video, "-vf", f"subtitles={
|
| 99 |
if result.returncode == 0:
|
| 100 |
print("FFmpeg executado com sucesso.")
|
| 101 |
else:
|
|
|
|
| 11 |
import uuid
|
| 12 |
import subprocess
|
| 13 |
|
|
|
|
| 14 |
ZipFile("ffmpeg.zip").extractall()
|
| 15 |
st = os.stat('ffmpeg')
|
| 16 |
os.chmod('ffmpeg', st.st_mode | stat.S_IEXEC)
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
def process_video(Video, target_language):
|
| 28 |
+
current_path = os.getcwd()
|
| 29 |
print("Iniciando process_video")
|
| 30 |
common_uuid = uuid.uuid4()
|
| 31 |
print("Checking FFmpeg availability...")
|
|
|
|
| 39 |
print("Iniciando transcrição com Whisper")
|
| 40 |
segments, _ = whisper_model.transcribe(audio_file, beam_size=5)
|
| 41 |
segments = list(segments)
|
| 42 |
+
transcript_file = f"{current_path}/{common_uuid}.srt"
|
| 43 |
|
| 44 |
# Create a list to hold the translated lines.
|
| 45 |
translated_lines = []
|
|
|
|
| 93 |
print(f"{transcript_file} exists.")
|
| 94 |
else:
|
| 95 |
print(f"{transcript_file} does not exist.")
|
| 96 |
+
#transcript_file_abs_path = os.path.abspath(transcript_file)
|
| 97 |
try:
|
| 98 |
+
result = subprocess.run(["ffmpeg", "-i", Video, "-vf", f"subtitles={transcript_file}", output_video], capture_output=True, text=True)
|
| 99 |
if result.returncode == 0:
|
| 100 |
print("FFmpeg executado com sucesso.")
|
| 101 |
else:
|