-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from kadirnar/add-test-file
πββοΈ Add test code and Runpod platform support
- Loading branch information
Showing
5 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ pre-commit==3.4.0 | |
autollm>=0.1.9 | ||
speechbrain>=0.5.16 | ||
bitsandbytes | ||
hqq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
apt-get update | ||
apt install ffmpeg nvtop -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import time | ||
|
||
import torch | ||
from pipelines.whisper import SpeechToTextPipeline | ||
from transformers import BitsAndBytesConfig, HqqConfig | ||
from utils.download_utils import download_and_convert_to_mp3 | ||
|
||
url = "https://www.youtube.com/watch?v=di3rHkEZuUw" | ||
audio_path = download_and_convert_to_mp3(url) | ||
|
||
hqq_config = HqqConfig( | ||
nbits=1, group_size=64, quant_zero=False, quant_scale=False, axis=0) # axis=0 is used by default | ||
|
||
bnb_config = BitsAndBytesConfig( | ||
load_in_4bit=True, | ||
bnb_4bit_quant_type="nf4", | ||
bnb_4bit_compute_dtype=torch.bfloat16, | ||
bnb_4bit_use_double_quant=True, | ||
) | ||
model = SpeechToTextPipeline( | ||
model_id="distil-whisper/distil-large-v3", quant_config=bnb_config) # or bnb_config | ||
|
||
start_event = torch.cuda.Event(enable_timing=True) | ||
end_event = torch.cuda.Event(enable_timing=True) | ||
|
||
start_event.record() | ||
transcript = model( | ||
audio_path="testv0.mp3", | ||
chunk_length_s=30, | ||
stride_length_s=5, | ||
max_new_tokens=128, | ||
batch_size=100, | ||
language="english", | ||
return_timestamps=False) | ||
end_event.record() | ||
|
||
torch.cuda.synchronize() | ||
elapsed_time_ms = start_event.elapsed_time(end_event) | ||
print(f"Execution time: {elapsed_time_ms}ms") |