Skip to content

Commit

Permalink
style: name based OpenAI document (minimum diff)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftnext authored Mar 28, 2024
1 parent 50e006b commit 42668ba
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions speech_recognition/recognizers/whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def recognize_whisper_api(
raise SetupError("Set environment variable ``OPENAI_API_KEY``")

try:
from openai import OpenAI
import openai
except ImportError:
raise SetupError(
"missing openai module: ensure that openai is set up correctly."
Expand All @@ -38,9 +38,6 @@ def recognize_whisper_api(
wav_data = BytesIO(audio_data.get_wav_data())
wav_data.name = "SpeechRecognition_audio.wav"

openai = OpenAI(api_key=api_key)
transcript = openai.audio.transcriptions.create(
file=wav_data, model=model
)

client = openai.OpenAI(api_key=api_key)
transcript = client.audio.transcriptions.create(file=wav_data, model=model)
return transcript.text

0 comments on commit 42668ba

Please sign in to comment.