washeed commited on
Commit
007bee8
1 Parent(s): 5ed7574

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +45 -0
README.md CHANGED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # to run
2
+ simply install chocolatey run this on your cmd:
3
+ @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
4
+
5
+ after that install ffmpeg in your device using choco install by running this on cmd after:
6
+ choco install ffmpeg
7
+
8
+ install dependencies in python IDE using:
9
+ pip install --upgrade pip
10
+ pip install --upgrade git+https://github.com/huggingface/transformers.git accelerate datasets[audio]
11
+
12
+ then lastly to inference the model:
13
+
14
+ import torch
15
+ from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
16
+
17
+
18
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
19
+ torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
20
+
21
+ model_id = "washeed/audio-transcribe"
22
+
23
+ model = AutoModelForSpeechSeq2Seq.from_pretrained(
24
+ model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
25
+ )
26
+ model.to(device)
27
+
28
+ processor = AutoProcessor.from_pretrained(model_id)
29
+
30
+ pipe = pipeline(
31
+ "automatic-speech-recognition",
32
+ model=model,
33
+ tokenizer=processor.tokenizer,
34
+ feature_extractor=processor.feature_extractor,
35
+ max_new_tokens=128,
36
+ chunk_length_s=30,
37
+ batch_size=16,
38
+ return_timestamps=True,
39
+ torch_dtype=torch_dtype,
40
+ device=device,
41
+ )
42
+
43
+ result = pipe("audio.mp3")
44
+ print(result["text"])
45
+