Skip to content

Commit

Permalink
whisper model update + minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ishanExtreme committed Feb 5, 2024
1 parent 6be050b commit f41d44b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,4 @@ rolegenie/media/
templates.py
newrelic.ini
__pycache__/
audios/*
audios/
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ nvidia-cusolver-cu11==11.4.0.1
nvidia-cusparse-cu11==11.7.4.91
nvidia-nccl-cu11==2.14.3
nvidia-nvtx-cu11==11.7.91
openai-whisper==20230314
openai-whisper==20231117
python-dotenv==1.0.0
regex==2023.6.3
requests==2.31.0
Expand Down
7 changes: 5 additions & 2 deletions routes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import uuid
import json

Expand Down Expand Up @@ -29,8 +30,10 @@ async def transcribe(request):
status_code=400,
content={"status": 400, "message": "Bad Request", "data": {}},
)

file_path = f"{str(ROOT_DIR)}/audios/{str(uuid.uuid4())}.mp3"
audio_directory = f"{str(ROOT_DIR)}/audios"
if not os.path.exists(audio_directory):
os.makedirs(audio_directory)
file_path = f"{audio_directory}/{str(uuid.uuid4())}.mp3"
with open(file_path, "wb") as f:
f.write(audio.file.read())

Expand Down
2 changes: 2 additions & 0 deletions routes_definition/transcribe/transcribe.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import whisper


def transcribe_helper(model: whisper.Whisper, audio_path: str, language: str):
result = model.transcribe(audio_path, language=language)
os.remove(audio_path)

print(result)
return result["text"]

0 comments on commit f41d44b

Please sign in to comment.