User Tools

Site Tools


ai:speech-to-text

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ai:speech-to-text [2025/08/21 13:28] – created Wulf Rajekai:speech-to-text [2025/08/21 14:19] (current) Wulf Rajek
Line 7: Line 7:
  
 https://github.com/speaches-ai/speaches https://github.com/speaches-ai/speaches
 +
 +
 +OpenAI/Whisper example python script with changed base url
 +
 +<code python>
 +mkdir transcribe
 +cd transcribe
 +python -m venv venv
 +source venv/bin/activate
 +pip install openai
 +
 +cat >> trans.py << EOD
 +#!/home/user/transcribe/venv/bin/python3
 +from openai import OpenAI
 +import sys,os
 +
 +def usage():
 +    print("Usage: "+os.path.basename(__file__)+" inputfile [outputfile]")
 +    print(" inputfile \t\tInput file to transcribe")
 +    print(" outputfile\tOptional: Filename to store transcription to")
 +    exit(1)
 +    
 +try:
 +    inputfile = sys.argv[1]
 +except Exception as e:
 +    usage()
 +
 +client = OpenAI(base_url="http://192.168.xx.xx:8010/v1", api_key="not needed")
 +audio_file= open(inputfile, "rb")
 +
 +transcription = client.audio.transcriptions.create(
 +    model="Systran/faster-whisper-large-v3", 
 +    file=audio_file
 +)
 +
 +try:
 +    outputfile = sys.argv[2]
 +    with open(sys.argv[2], "w") as text_file:
 +        text_file.write(transcription.text)
 +except:
 +    print(transcription.text)
 +EOD
 +</code>
  
  
ai/speech-to-text.txt · Last modified: by Wulf Rajek