bofenghuang commited on
Commit
cc46c30
β€’
1 Parent(s): 5140605
Files changed (2) hide show
  1. run_demo_ct2.py +1 -0
  2. run_demo_hf.py +26 -20
run_demo_ct2.py CHANGED
@@ -114,6 +114,7 @@ def maybe_load_cached_pipeline(model_name):
114
  # downloaded_model_path = hf_hub_download(repo_id=model_name, filename=CHECKPOINT_FILENAME)
115
  # downloaded_model_path = snapshot_download(repo_id=model_name)
116
  downloaded_model_path = snapshot_download(repo_id=model_name, allow_patterns="ctranslate2/*")
 
117
 
118
  # model = whisper.load_model(downloaded_model_path, device=device)
119
  model = WhisperModel(downloaded_model_path, device=device, compute_type="float16")
 
114
  # downloaded_model_path = hf_hub_download(repo_id=model_name, filename=CHECKPOINT_FILENAME)
115
  # downloaded_model_path = snapshot_download(repo_id=model_name)
116
  downloaded_model_path = snapshot_download(repo_id=model_name, allow_patterns="ctranslate2/*")
117
+ downloaded_model_path = f"{downloaded_model_path}/ctranslate2"
118
 
119
  # model = whisper.load_model(downloaded_model_path, device=device)
120
  model = WhisperModel(downloaded_model_path, device=device, compute_type="float16")
run_demo_hf.py CHANGED
@@ -11,7 +11,11 @@ from transformers.utils.logging import disable_progress_bar
11
  warnings.filterwarnings("ignore")
12
  disable_progress_bar()
13
 
14
- MODEL_NAME = "bofenghuang/whisper-large-v2-cv11-french"
 
 
 
 
15
  CHUNK_LENGTH_S = 30
16
 
17
  logging.basicConfig(
@@ -80,38 +84,38 @@ demo = gr.Blocks()
80
  mf_transcribe = gr.Interface(
81
  fn=transcribe,
82
  inputs=[
83
- gr.inputs.Audio(source="microphone", type="filepath", optional=True, label="Record"),
84
- gr.inputs.Audio(source="upload", type="filepath", optional=True, label="Upload File"),
85
  ],
86
  # outputs="text",
87
- outputs=gr.outputs.Textbox(label="Transcription"),
88
- layout="horizontal",
89
  theme="huggingface",
90
  title="Whisper French Demo πŸ‡«πŸ‡· : Transcribe Audio",
91
- description=(
92
- "Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the the fine-tuned"
93
- f" checkpoint [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and πŸ€— Transformers to transcribe audio files"
94
- " of arbitrary length."
95
- ),
96
  allow_flagging="never",
97
  )
98
 
99
  yt_transcribe = gr.Interface(
100
  fn=yt_transcribe,
101
- inputs=[gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL")],
102
  # outputs=["html", "text"],
103
  outputs=[
104
- gr.outputs.HTML(label="YouTube Page"),
105
- gr.outputs.Textbox(label="Transcription"),
106
  ],
107
- layout="horizontal",
108
  theme="huggingface",
109
  title="Whisper French Demo πŸ‡«πŸ‡· : Transcribe YouTube",
110
- description=(
111
- "Transcribe long-form YouTube videos with the click of a button! Demo uses the the fine-tuned checkpoint:"
112
- f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and πŸ€— Transformers to transcribe audio files of"
113
- " arbitrary length."
114
- ),
115
  allow_flagging="never",
116
  )
117
 
@@ -119,4 +123,6 @@ with demo:
119
  gr.TabbedInterface([mf_transcribe, yt_transcribe], ["Transcribe Audio", "Transcribe YouTube"])
120
 
121
  # demo.launch(server_name="0.0.0.0", debug=True, share=True)
122
- demo.launch(enable_queue=True)
 
 
 
11
  warnings.filterwarnings("ignore")
12
  disable_progress_bar()
13
 
14
+ # MODEL_NAME = "bofenghuang/whisper-large-v2-cv11-french"
15
+ MODEL_NAME = "bofenghuang/whisper-large-v3-french"
16
+ # MODEL_NAME = "/home/bhuang/transformers/examples/pytorch/speech-recognition/outputs/hf_whisper/whisper-large-v3-ft-french-pnc-ep5-bs280-lr4e6-wd001-audioaug-specaug"
17
+ # MODEL_NAME = "/home/bhuang/transformers/examples/pytorch/speech-recognition/outputs/hf_whisper/tmp_model"
18
+ # MODEL_NAME = "/projects/bhuang/models/asr/public/whisper-large-v3-french"
19
  CHUNK_LENGTH_S = 30
20
 
21
  logging.basicConfig(
 
84
  mf_transcribe = gr.Interface(
85
  fn=transcribe,
86
  inputs=[
87
+ gr.components.Audio(sources="microphone", type="filepath", label="Record"),
88
+ gr.components.Audio(sources="upload", type="filepath", label="Upload File"),
89
  ],
90
  # outputs="text",
91
+ outputs=gr.components.Textbox(label="Transcription", show_copy_button=True),
92
+ # layout="horizontal",
93
  theme="huggingface",
94
  title="Whisper French Demo πŸ‡«πŸ‡· : Transcribe Audio",
95
+ # description=(
96
+ # "Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the the fine-tuned"
97
+ # f" checkpoint [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and πŸ€— Transformers to transcribe audio files"
98
+ # " of arbitrary length."
99
+ # ),
100
  allow_flagging="never",
101
  )
102
 
103
  yt_transcribe = gr.Interface(
104
  fn=yt_transcribe,
105
+ inputs=[gr.components.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL")],
106
  # outputs=["html", "text"],
107
  outputs=[
108
+ gr.components.HTML(label="YouTube Page"),
109
+ gr.components.Textbox(label="Transcription", show_copy_button=True),
110
  ],
111
+ # layout="horizontal",
112
  theme="huggingface",
113
  title="Whisper French Demo πŸ‡«πŸ‡· : Transcribe YouTube",
114
+ # description=(
115
+ # "Transcribe long-form YouTube videos with the click of a button! Demo uses the the fine-tuned checkpoint:"
116
+ # f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and πŸ€— Transformers to transcribe audio files of"
117
+ # " arbitrary length."
118
+ # ),
119
  allow_flagging="never",
120
  )
121
 
 
123
  gr.TabbedInterface([mf_transcribe, yt_transcribe], ["Transcribe Audio", "Transcribe YouTube"])
124
 
125
  # demo.launch(server_name="0.0.0.0", debug=True, share=True)
126
+ # demo.launch(enable_queue=True)
127
+ # see https://github.com/gradio-app/gradio/issues/2551
128
+ demo.queue(max_size=10).launch(server_name="0.0.0.0", debug=True, share=True, ssl_certfile="/home/bhuang/tools/cert.pem", ssl_keyfile="/home/bhuang/tools/key.pem", ssl_verify=False)