-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77bf097
commit 7ff6764
Showing
3 changed files
with
56 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import argparse | ||
|
||
from openai import OpenAI | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Get transcription of an audio file") | ||
parser.add_argument("--model", type=str, default="whisper-1", help="Model name") | ||
# File name | ||
parser.add_argument("--file_path", type=str, required=True, help="Path to the audio file") | ||
args = parser.parse_args() | ||
## | ||
stt_url = os.getenv("STT_OPENAI_BASE_URL", None) | ||
assert stt_url is not None, "STT_OPENAI_BASE_URL environment variable is not set" | ||
stt_api_key = os.getenv('STT_OPENAI_API_KEY', 'EMPTY') | ||
|
||
# Read the audio file | ||
audio_file = open(args.file_path, "rb") | ||
client = OpenAI(base_url=stt_url, api_key=stt_api_key) | ||
transcription = client.audio.transcriptions.create( | ||
model=args.model, | ||
file=audio_file | ||
) | ||
print(f"Audio file successfully transcribed: '{transcription.text}'") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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