Anushkabhat9 commited on
Commit
9bcf657
·
1 Parent(s): 7487e83

Push app changes

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +23 -0
  3. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ /DeepLearning/myenv
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import pipeline
3
+ from datasets import load_dataset
4
+
5
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
6
+
7
+ pipe = pipeline(
8
+ "automatic-speech-recognition",
9
+ model="openai/whisper-small",
10
+ chunk_length_s=30,
11
+ device=device,
12
+ )
13
+
14
+ ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
15
+ sample = ds[0]["audio"]
16
+
17
+ prediction = pipe(sample.copy(), batch_size=8)["text"]
18
+
19
+
20
+ # we can also return timestamps for the predictions
21
+ prediction = pipe(sample.copy(), batch_size=8, return_timestamps=True)["chunks"]
22
+
23
+ print(prediction[0]['text'])
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch