Spaces:
Build error
Build error
Добавлено сохранение временных файлов в определённый путь
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ from speech_recognition import get_speech_recognition_pipeline
|
|
| 10 |
from yandex_summarization import yandex_summary
|
| 11 |
|
| 12 |
speech_recognition_pipeline = get_speech_recognition_pipeline()
|
| 13 |
-
|
| 14 |
|
| 15 |
def extract_audio_chunks(video_file: str, chunk_length_ms: int = 60 * 1000):
|
| 16 |
"""
|
|
@@ -25,7 +25,7 @@ def extract_audio_chunks(video_file: str, chunk_length_ms: int = 60 * 1000):
|
|
| 25 |
audio = video.audio
|
| 26 |
|
| 27 |
# Создаём новый объект AudioSegment, при помощи которого будем перемещаться по аудио дорожке
|
| 28 |
-
audio_buffer = "temp_audio.wav"
|
| 29 |
audio.write_audiofile(audio_buffer, codec="pcm_s16le", nbytes=2, fps=44100)
|
| 30 |
audio_segment = AudioSegment.from_file(audio_buffer, format="wav")
|
| 31 |
|
|
@@ -53,7 +53,7 @@ def transcribe_video(video_file: str) -> list[str]:
|
|
| 53 |
|
| 54 |
for chunk in extract_audio_chunks(video_file):
|
| 55 |
# Save the audio chunk to a temporary file
|
| 56 |
-
temp_file = "temp_chunk.wav"
|
| 57 |
chunk.export(temp_file, format="wav")
|
| 58 |
|
| 59 |
# Транскрибация куска аудио
|
|
|
|
| 10 |
from yandex_summarization import yandex_summary
|
| 11 |
|
| 12 |
speech_recognition_pipeline = get_speech_recognition_pipeline()
|
| 13 |
+
temp_path = "/data"
|
| 14 |
|
| 15 |
def extract_audio_chunks(video_file: str, chunk_length_ms: int = 60 * 1000):
|
| 16 |
"""
|
|
|
|
| 25 |
audio = video.audio
|
| 26 |
|
| 27 |
# Создаём новый объект AudioSegment, при помощи которого будем перемещаться по аудио дорожке
|
| 28 |
+
audio_buffer = temp_path / "temp_audio.wav"
|
| 29 |
audio.write_audiofile(audio_buffer, codec="pcm_s16le", nbytes=2, fps=44100)
|
| 30 |
audio_segment = AudioSegment.from_file(audio_buffer, format="wav")
|
| 31 |
|
|
|
|
| 53 |
|
| 54 |
for chunk in extract_audio_chunks(video_file):
|
| 55 |
# Save the audio chunk to a temporary file
|
| 56 |
+
temp_file = temp_path / "temp_chunk.wav"
|
| 57 |
chunk.export(temp_file, format="wav")
|
| 58 |
|
| 59 |
# Транскрибация куска аудио
|