altryne commited on
Commit
31bc5a1
·
unverified ·
1 Parent(s): 70bd663

Created the transcribe_translate gradio API endpoint, that will be sync

Browse files
Files changed (2) hide show
  1. download.py +1 -1
  2. utils/apis.py +11 -0
download.py CHANGED
@@ -209,7 +209,7 @@ def caption_generator(social_media_url,uid, language="Autodetect", model_size=mo
209
  raise
210
  print(f"Finished processing {uid} file, returning results")
211
  print(whisper_result_captions)
212
- return 'success', whisper_result_captions
213
 
214
  # Run whisper with translation task enabled (and save to different srt file)
215
  # Call anvil background task with both files, and both the plain texts
 
209
  raise
210
  print(f"Finished processing {uid} file, returning results")
211
  print(whisper_result_captions)
212
+ return 'success', whisper_result_captions, detected_language
213
 
214
  # Run whisper with translation task enabled (and save to different srt file)
215
  # Call anvil background task with both files, and both the plain texts
utils/apis.py CHANGED
@@ -76,6 +76,17 @@ def caption(downloadable_url="", uid="", language="Autodetect", override_model_s
76
  anvil.server.launch_background_task('add_captions_to_video', uid, whisper_result_captions)
77
  return {'status': status, 'message': 'started a background process to upload subtitles to {uid}' }
78
 
 
 
 
 
 
 
 
 
 
 
 
79
  def render_api_elements(url_input, download_status, output_text, sub_video, output_file):
80
  with gr.Group(elem_id='fake_ass_group') as api_buttons:
81
  # This is a hack to get APIs registered with the blocks interface
 
76
  anvil.server.launch_background_task('add_captions_to_video', uid, whisper_result_captions)
77
  return {'status': status, 'message': 'started a background process to upload subtitles to {uid}' }
78
 
79
+
80
+ def transcribe_translate(downloadable_url="", uid="", language="Autodetect", override_model_size=""):
81
+ """
82
+ :param media_id: The twitter media ID object
83
+ :param user_id_str: The twitter user ID string
84
+ :param tweet_url: tweet URL can potentially not exist in the future, so we can upload on behalf of the user
85
+ :return:
86
+ """
87
+ status, whisper_result_captions, detected_language = caption_generator(downloadable_url, uid, language, override_model_size)
88
+ return {'status': status, 'captions': whisper_result_captions, 'language': detected_language}
89
+
90
  def render_api_elements(url_input, download_status, output_text, sub_video, output_file):
91
  with gr.Group(elem_id='fake_ass_group') as api_buttons:
92
  # This is a hack to get APIs registered with the blocks interface