Upload 2 files
Browse files- app.py +35 -0
- requirements.txt +19 -0
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
import numpy as np
|
4 |
+
import moviepy.editor as mp
|
5 |
+
|
6 |
+
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
|
7 |
+
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr") # Example for English to French
|
8 |
+
|
9 |
+
def transcribe(video_file):
|
10 |
+
# Load video file and extract audio
|
11 |
+
audio_file = mp.AudioFileClip(video_file).write_audiofile("temp_audio.wav")
|
12 |
+
result = transcriber("temp_audio.wav")
|
13 |
+
return result['text']
|
14 |
+
|
15 |
+
def translate(text):
|
16 |
+
return translator(text)[0]['translation_text']
|
17 |
+
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("# Curify Studio Demo")
|
20 |
+
|
21 |
+
with gr.Tab("Transcription"):
|
22 |
+
video_input = gr.File(label="Upload Video File")
|
23 |
+
transcribe_output = gr.Textbox(label="Transcription Output", lines=10)
|
24 |
+
transcribe_button = gr.Button("Transcribe")
|
25 |
+
|
26 |
+
transcribe_button.click(fn=transcribe, inputs=video_input, outputs=transcribe_output)
|
27 |
+
|
28 |
+
with gr.Tab("Translation"):
|
29 |
+
text_input = gr.Textbox(label="Text to Translate")
|
30 |
+
translate_output = gr.Textbox(label="Translation Output", lines=10)
|
31 |
+
translate_button = gr.Button("Translate")
|
32 |
+
|
33 |
+
translate_button.click(fn=translate, inputs=text_input, outputs=translate_output)
|
34 |
+
|
35 |
+
demo.launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
qrcode
|
2 |
+
flask
|
3 |
+
gradio
|
4 |
+
newspaper3k
|
5 |
+
transformers
|
6 |
+
sentence-transformers
|
7 |
+
openai
|
8 |
+
todoist-api-python
|
9 |
+
flask
|
10 |
+
twilio
|
11 |
+
fastapi
|
12 |
+
uvicorn
|
13 |
+
moviepy
|
14 |
+
ffmpy
|
15 |
+
google-cloud-storage
|
16 |
+
fpdf
|
17 |
+
markdown
|
18 |
+
nest_asyncio
|
19 |
+
reportlab
|