neimp commited on
Commit
0e9e3b5
·
1 Parent(s): 94bb963

Добавлен параметр пути сохранения файлов

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -10,7 +10,8 @@ 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
- temp_path = "/data"
 
14
 
15
  def extract_audio_chunks(video_file: str, chunk_length_ms: int = 60 * 1000):
16
  """
@@ -25,7 +26,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_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,7 +54,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_path / "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
+ data_path = os.environ.get("DATA_PATH", default="/data")
14
+
15
 
16
  def extract_audio_chunks(video_file: str, chunk_length_ms: int = 60 * 1000):
17
  """
 
26
  audio = video.audio
27
 
28
  # Создаём новый объект AudioSegment, при помощи которого будем перемещаться по аудио дорожке
29
+ audio_buffer = os.path.join(data_path, "temp_audio.wav")
30
  audio.write_audiofile(audio_buffer, codec="pcm_s16le", nbytes=2, fps=44100)
31
  audio_segment = AudioSegment.from_file(audio_buffer, format="wav")
32
 
 
54
 
55
  for chunk in extract_audio_chunks(video_file):
56
  # Save the audio chunk to a temporary file
57
+ temp_file = os.path.join(data_path, "temp_chunk.wav")
58
  chunk.export(temp_file, format="wav")
59
 
60
  # Транскрибация куска аудио