Spaces:
Runtime error
Runtime error
gamingflexer
commited on
Commit
·
23f8016
1
Parent(s):
eeea261
Add dependencies and update API key handling
Browse files- requirements.txt +4 -1
- src/app_utils.py +2 -6
- src/audio_text.py +17 -17
requirements.txt
CHANGED
|
@@ -1,2 +1,5 @@
|
|
| 1 |
gradio
|
| 2 |
-
pandas
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
+
pandas
|
| 3 |
+
soundfile
|
| 4 |
+
langchain==0.1.6
|
| 5 |
+
openai
|
src/app_utils.py
CHANGED
|
@@ -1,13 +1,9 @@
|
|
| 1 |
from textwrap import dedent
|
| 2 |
-
import base64
|
| 3 |
-
import requests
|
| 4 |
from openai import OpenAI
|
| 5 |
-
import os
|
| 6 |
from decouple import config
|
| 7 |
-
import json
|
| 8 |
-
|
| 9 |
-
OPENAI_API_KEY = config('OPENAI_API_KEY', default="")
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
voice_edit = dedent("""
|
| 13 |
### Instruction:
|
|
|
|
| 1 |
from textwrap import dedent
|
|
|
|
|
|
|
| 2 |
from openai import OpenAI
|
|
|
|
| 3 |
from decouple import config
|
| 4 |
+
import json,os
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 7 |
|
| 8 |
voice_edit = dedent("""
|
| 9 |
### Instruction:
|
src/audio_text.py
CHANGED
|
@@ -6,7 +6,7 @@ from openai import OpenAI
|
|
| 6 |
from decouple import config
|
| 7 |
import os
|
| 8 |
|
| 9 |
-
OPENAI_API_KEY =
|
| 10 |
client = OpenAI()
|
| 11 |
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
| 12 |
|
|
@@ -18,22 +18,22 @@ os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
-
def whisper_pipeline(audio_path):
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
def whisper_openai(audio_path):
|
| 39 |
audio_file= open(audio_path, "rb")
|
|
|
|
| 6 |
from decouple import config
|
| 7 |
import os
|
| 8 |
|
| 9 |
+
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 10 |
client = OpenAI()
|
| 11 |
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
| 12 |
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
+
# def whisper_pipeline(audio_path):
|
| 22 |
+
# model = whisper.load_model("medium")
|
| 23 |
+
# # load audio and pad/trim it to fit 30 seconds
|
| 24 |
+
# audio = whisper.load_audio(audio_path)
|
| 25 |
+
# audio = whisper.pad_or_trim(audio)
|
| 26 |
+
# # make log-Mel spectrogram and move to the same device as the model
|
| 27 |
+
# mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
| 28 |
+
# # detect the spoken language
|
| 29 |
+
# _, probs = model.detect_language(mel)
|
| 30 |
+
# print(f"Detected language: {max(probs, key=probs.get)}")
|
| 31 |
+
# # decode the audio
|
| 32 |
+
# options = whisper.DecodingOptions()
|
| 33 |
+
# result = whisper.decode(model, mel, options)
|
| 34 |
+
# # print the recognized text
|
| 35 |
+
# print(result.text)
|
| 36 |
+
# return result.text
|
| 37 |
|
| 38 |
def whisper_openai(audio_path):
|
| 39 |
audio_file= open(audio_path, "rb")
|