XINZHANG-Geotab commited on
Commit
4f03767
·
verified ·
1 Parent(s): fafc499

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -4,10 +4,10 @@ from langchain_openai import ChatOpenAI
4
  from utils import RefineDataSummarizer
5
  import os
6
 
7
- def transcript(file_dir, model_type):
8
  model_dir = os.path.join('models', model_type)
9
  model = whisper.load_model(model_dir)
10
- result = model.transcribe(file_dir, language='English', task='transcribe')
11
 
12
  lines = [s['text'] for s in result['segments']]
13
  text = ''
@@ -37,6 +37,8 @@ with gr.Blocks() as demo:
37
  file_output = gr.File()
38
  upload_button = gr.UploadButton("Click to Upload a File", file_types=["audio", "video"], file_count="single")
39
  upload_button.upload(upload_file, upload_button, file_output)
 
 
40
  model_type = gr.Dropdown(
41
  [
42
  "tiny.en.pt",
@@ -74,6 +76,7 @@ with gr.Blocks() as demo:
74
  fn=transcript,
75
  inputs=[
76
  file_output,
 
77
  model_type
78
  ],
79
  outputs=[transcript_text]
 
4
  from utils import RefineDataSummarizer
5
  import os
6
 
7
+ def transcript(file_dir, language, model_type):
8
  model_dir = os.path.join('models', model_type)
9
  model = whisper.load_model(model_dir)
10
+ result = model.transcribe(file_dir, language=language, task='transcribe')
11
 
12
  lines = [s['text'] for s in result['segments']]
13
  text = ''
 
37
  file_output = gr.File()
38
  upload_button = gr.UploadButton("Click to Upload a File", file_types=["audio", "video"], file_count="single")
39
  upload_button.upload(upload_file, upload_button, file_output)
40
+ language = gr.Dropdown(
41
+ ["English", "Chinese"], label="Transcript Language", value="English")
42
  model_type = gr.Dropdown(
43
  [
44
  "tiny.en.pt",
 
76
  fn=transcript,
77
  inputs=[
78
  file_output,
79
+ language,
80
  model_type
81
  ],
82
  outputs=[transcript_text]