ai:speech-to-text
Differences
This shows you the differences between two versions of the page.
| ai:speech-to-text [2025/08/21 13:28] – created Wuff | ai:speech-to-text [2025/08/21 14:19] (current) – Wuff | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| https:// | https:// | ||
| + | |||
| + | |||
| + | OpenAI/ | ||
| + | |||
| + | <code python> | ||
| + | mkdir transcribe | ||
| + | cd transcribe | ||
| + | python -m venv venv | ||
| + | source venv/ | ||
| + | pip install openai | ||
| + | |||
| + | cat >> trans.py << EOD | ||
| + | # | ||
| + | from openai import OpenAI | ||
| + | import sys,os | ||
| + | |||
| + | def usage(): | ||
| + | print(" | ||
| + | print(" | ||
| + | print(" | ||
| + | exit(1) | ||
| + | | ||
| + | try: | ||
| + | inputfile = sys.argv[1] | ||
| + | except Exception as e: | ||
| + | usage() | ||
| + | |||
| + | client = OpenAI(base_url=" | ||
| + | audio_file= open(inputfile, | ||
| + | |||
| + | transcription = client.audio.transcriptions.create( | ||
| + | model=" | ||
| + | file=audio_file | ||
| + | ) | ||
| + | |||
| + | try: | ||
| + | outputfile = sys.argv[2] | ||
| + | with open(sys.argv[2], | ||
| + | text_file.write(transcription.text) | ||
| + | except: | ||
| + | print(transcription.text) | ||
| + | EOD | ||
| + | </ | ||
ai/speech-to-text.1755779310.txt.gz · Last modified: by Wuff