fengye commited on
Commit
132e068
1 Parent(s): a22067d

test202410141642

Browse files
Files changed (2) hide show
  1. app.py +27 -0
  2. model.json +0 -0
app.py CHANGED
@@ -3,5 +3,32 @@ import gradio as gr
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  demo.launch()
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
6
+
7
+ import torch
8
+ from transformers import pipeline
9
+ speech_recognizer = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
10
+
11
+ from datasets import load_dataset, Audio
12
+
13
+ dataset = load_dataset("PolyAI/minds14", name="en-US", split="train")
14
+
15
+ dataset = dataset.cast_column("audio", Audio(sampling_rate=speech_recognizer.feature_extractor.sampling_rate))
16
+
17
+ result = speech_recognizer(dataset[:4]["audio"])
18
+ print([d["text"] for d in result])
19
+
20
+ # ==
21
+
22
+ model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
23
+
24
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
25
+
26
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
27
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
28
+
29
+ classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
30
+ classifier("Nous sommes très heureux de vous présenter la bibliothèque 🤗 Transformers.")
31
+
32
+
33
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
34
  demo.launch()
model.json ADDED
File without changes