eaglelandsonce commited on
Commit
e31036d
1 Parent(s): 651ae26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -16,23 +16,24 @@ def get_audio(url):
16
  os.rename(out_file, new_file)
17
  return new_file
18
 
19
- def get_text(url):
20
  result = model.transcribe(get_audio(url))
21
  return result['text']
22
 
 
 
 
 
 
 
23
  def get_summary(url):
24
- article = get_text(url)
25
  b = summarizer(article)
26
- b = b[0]['summary_text']
27
- return b
28
-
29
- def handle_file(file):
30
- # Mock function to handle uploaded files
31
- return f"Received {file.name} of type {file.type}"
32
 
33
  with gr.Blocks() as demo:
34
  gr.Markdown("<h1><center>Youtube video transcription with OpenAI's Whisper</center></h1>")
35
- gr.Markdown("<center>Enter the link of any youtube video to get the transcription of the video and a summary of the video in the form of text.</center>")
36
 
37
  with gr.Tab('Get the transcription of any Youtube video'):
38
  with gr.Row():
@@ -46,15 +47,14 @@ with gr.Blocks() as demo:
46
  output_text = gr.Textbox(placeholder='Summary text of the Youtube Video', label='Summary')
47
  result_button = gr.Button('Get Summary')
48
 
49
- # Adding the new tab for drag and drop
50
- with gr.Tab('Upload .doc, .txt, .csv files'):
51
  with gr.Row():
52
- file_input = gr.File(label="Drag & Drop File", type=[".doc", ".txt", ".csv"])
53
- file_output = gr.Textbox(placeholder='File received', label='File Info')
54
- file_button = gr.Button('Upload File')
55
 
56
  result_button.click(get_summary, inputs=input_text, outputs=output_text)
57
- result_button_1.click(get_text, inputs=input_text_1, outputs=output_text_1)
58
- file_button.click(handle_file, inputs=file_input, outputs=file_output)
59
 
60
- demo.launch(debug=True)
 
16
  os.rename(out_file, new_file)
17
  return new_file
18
 
19
+ def get_text_from_url(url):
20
  result = model.transcribe(get_audio(url))
21
  return result['text']
22
 
23
+ def get_text_from_file(file_path):
24
+ # Assuming the file_path is the path to the MP4 file
25
+ # You would need to extract audio from the MP4 and then transcribe it
26
+ # For simplicity, I'm returning a placeholder text
27
+ return "Transcription from uploaded MP4 file goes here."
28
+
29
  def get_summary(url):
30
+ article = get_text_from_url(url)
31
  b = summarizer(article)
32
+ return b[0]['summary_text']
 
 
 
 
 
33
 
34
  with gr.Blocks() as demo:
35
  gr.Markdown("<h1><center>Youtube video transcription with OpenAI's Whisper</center></h1>")
36
+ gr.Markdown("<center>Enter the link of any youtube video or upload an MP4 file to get the transcription of the video and a summary of the video in the form of text.</center>")
37
 
38
  with gr.Tab('Get the transcription of any Youtube video'):
39
  with gr.Row():
 
47
  output_text = gr.Textbox(placeholder='Summary text of the Youtube Video', label='Summary')
48
  result_button = gr.Button('Get Summary')
49
 
50
+ with gr.Tab('Upload MP4 for Transcription'):
 
51
  with gr.Row():
52
+ input_file = gr.File(label="Upload MP4 File", type=["mp4"])
53
+ output_text_file = gr.Textbox(placeholder='Transcription of the uploaded video', label='Transcription')
54
+ result_button_file = gr.Button('Get Transcription from File')
55
 
56
  result_button.click(get_summary, inputs=input_text, outputs=output_text)
57
+ result_button_1.click(get_text_from_url, inputs=input_text_1, outputs=output_text_1)
58
+ result_button_file.click(get_text_from_file, inputs=input_file, outputs=output_text_file)
59
 
60
+ demo.launch(debug=True)