cptsubtext commited on
Commit
9fb8da4
·
1 Parent(s): c75a5bc

only one run

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -43,16 +43,14 @@ def transcribe_to_subtitle(audio_bytes, model_name):
43
 
44
  # Transcribe audio
45
  try:
46
- result = model.transcribe(audio_bytes, verbose=True)
47
- result.to_srt_vtt('audio.srt')
 
 
 
 
48
  except Exception as e:
49
  return {"error": f"Error during transcription: {str(e)}"}
50
-
51
- if translate:
52
- # Get text from speech for subtitles from audio file
53
- translation = model.transcribe(audio_bytes, verbose=True, task = 'translate')
54
- english_output = translation.text
55
- st.markdown(english_output, unsafe_allow_html=True)
56
 
57
  captions = pysrt.open("audio.srt")
58
  for caption in captions:
@@ -63,9 +61,7 @@ def transcribe_to_subtitle(audio_bytes, model_name):
63
 
64
  output = captions.text
65
  st.markdown(output, unsafe_allow_html=True)
66
-
67
-
68
-
69
  # Download option
70
  st.success("Transcription successful! Download subtitle file?")
71
  with open("audio.srt", "rb") as f:
 
43
 
44
  # Transcribe audio
45
  try:
46
+ if translate:
47
+ result = model.transcribe(audio_bytes, verbose=True, task = 'translate')
48
+ result.to_srt_vtt('audio.srt')
49
+ else:
50
+ result = model.transcribe(audio_bytes, verbose=True)
51
+ result.to_srt_vtt('audio.srt')
52
  except Exception as e:
53
  return {"error": f"Error during transcription: {str(e)}"}
 
 
 
 
 
 
54
 
55
  captions = pysrt.open("audio.srt")
56
  for caption in captions:
 
61
 
62
  output = captions.text
63
  st.markdown(output, unsafe_allow_html=True)
64
+
 
 
65
  # Download option
66
  st.success("Transcription successful! Download subtitle file?")
67
  with open("audio.srt", "rb") as f: