jvalero commited on
Commit
a4e0bf3
1 Parent(s): 165f4f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -5
app.py CHANGED
@@ -3,10 +3,17 @@ import torch
3
  from transformers import pipeline
4
  from transformers.pipelines.audio_utils import ffmpeg_read
5
  import gradio as gr
 
6
 
7
 
8
- model_id = "wav2vec2-base-vinyl_condition"
9
 
 
 
 
 
 
 
10
 
11
  def get_vinyl_condition(filepath):
12
  output = pipe(
@@ -17,18 +24,35 @@ def get_vinyl_condition(filepath):
17
  )
18
  return output[0]["label"]
19
 
20
- import gradio as gr
21
 
22
  demo = gr.Blocks()
23
 
24
 
 
 
 
25
  file_transcribe = gr.Interface(
26
  fn=get_vinyl_condition,
27
- inputs=gr.Audio(sources="upload", type="filepath"),
28
- outputs=gr.outputs.Textbox(),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  )
30
 
31
  with demo:
32
  gr.TabbedInterface([file_transcribe], ["Transcribe Audio File"])
33
 
34
- demo.launch(enable_queue=True)
 
3
  from transformers import pipeline
4
  from transformers.pipelines.audio_utils import ffmpeg_read
5
  import gradio as gr
6
+ import gradio as gr
7
 
8
 
9
+ MODEL_ID = "wav2vec2-base-vinyl_condition"
10
 
11
+ pipe = pipeline(
12
+ task="audio-classification",
13
+ model=MODEL_ID,
14
+ chunk_length_s=30,
15
+ device=device,
16
+ )
17
 
18
  def get_vinyl_condition(filepath):
19
  output = pipe(
 
24
  )
25
  return output[0]["label"]
26
 
 
27
 
28
  demo = gr.Blocks()
29
 
30
 
31
+
32
+ demo = gr.Blocks()
33
+
34
  file_transcribe = gr.Interface(
35
  fn=get_vinyl_condition,
36
+ inputs=[
37
+ gr.inputs.Audio(source="upload", optional=True, label="Audio file", type="filepath"),
38
+ ],
39
+ outputs="text",
40
+ layout="horizontal",
41
+ theme="huggingface",
42
+ title="Vinyl Demo: Get Vinyl Condition",
43
+ description=(
44
+ "Get your vinyl ocndition based on the golmine grading starndard! Demo uses the"
45
+ f" checkpoint [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to get the condition of audio files"
46
+ " of arbitrary length."
47
+ ),
48
+ examples=[
49
+ ["./example.flac"],
50
+ ],
51
+ cache_examples=True,
52
+ allow_flagging="never",
53
  )
54
 
55
  with demo:
56
  gr.TabbedInterface([file_transcribe], ["Transcribe Audio File"])
57
 
58
+ demo.launch(enable_queue=True)