kamau1 commited on
Commit
f459a06
·
verified ·
1 Parent(s): e45700a

Update pages/02_📼_Upload_Video_File.py

Browse files
Files changed (1) hide show
  1. pages/02_📼_Upload_Video_File.py +30 -0
pages/02_📼_Upload_Video_File.py CHANGED
@@ -2,6 +2,7 @@ import whisper
2
  import streamlit as st
3
  from streamlit_lottie import st_lottie
4
  from utils import write_vtt, write_srt
 
5
  import ffmpeg
6
  import requests
7
  from typing import Iterator
@@ -12,6 +13,9 @@ import os
12
 
13
  st.set_page_config(page_title="Semaitles", page_icon=":movie_camera:", layout="wide")
14
 
 
 
 
15
  # Define a function that we can use to load lottie files from a link.
16
  @st.cache(allow_output_mutation=True)
17
  def load_lottieurl(url: str):
@@ -102,7 +106,33 @@ def generate_subtitled_video(video, audio, transcript):
102
  video_with_subs = open("final.mp4", "rb")
103
  return video_with_subs
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
 
 
 
 
 
 
106
  def main():
107
  size = st.selectbox("Select Model Size (The larger the model, the more accurate the transcription will be, but it will take longer)", ["tiny", "base", "small", "medium", "large"], index=1)
108
  loaded_model = change_model(current_size, size)
 
2
  import streamlit as st
3
  from streamlit_lottie import st_lottie
4
  from utils import write_vtt, write_srt
5
+ from flores200_codes import flores_codes
6
  import ffmpeg
7
  import requests
8
  from typing import Iterator
 
13
 
14
  st.set_page_config(page_title="Semaitles", page_icon=":movie_camera:", layout="wide")
15
 
16
+ # Sema Translator
17
+ Public_Url = 'https://lewiskimaru-helloworld.hf.space' #endpoint
18
+
19
  # Define a function that we can use to load lottie files from a link.
20
  @st.cache(allow_output_mutation=True)
21
  def load_lottieurl(url: str):
 
106
  video_with_subs = open("final.mp4", "rb")
107
  return video_with_subs
108
 
109
+ def translate(userinput, target_lang, source_lang=None):
110
+ if source_lang:
111
+ url = f"{Public_Url}/translate_enter/"
112
+ data = {
113
+ "userinput": userinput,
114
+ "source_lang": source_lang,
115
+ "target_lang": target_lang,
116
+ }
117
+ response = requests.post(url, json=data)
118
+ result = response.json()
119
+ print(type(result))
120
+ source_lange = source_lang
121
+ translation = result['translated_text']
122
+
123
+ else:
124
+ url = f"{Public_Url}/translate_detect/"
125
+ data = {
126
+ "userinput": userinput,
127
+ "target_lang": target_lang,
128
+ }
129
 
130
+ response = requests.post(url, json=data)
131
+ result = response.json()
132
+ source_lange = result['source_language']
133
+ translation = result['translated_text']
134
+ return source_lange, translation
135
+
136
  def main():
137
  size = st.selectbox("Select Model Size (The larger the model, the more accurate the transcription will be, but it will take longer)", ["tiny", "base", "small", "medium", "large"], index=1)
138
  loaded_model = change_model(current_size, size)