Code #7829
Closed
silje7
started this conversation in
General | 讨论
Code
#7829
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
import os
import openai
OPENAI API-SCHLÜSSEL HIER EINTRAGEN
openai.api_key = "sk-..."
Verzeichnis mit Audiodateien
audio_verzeichnis = "./audios"
Unterstützte Audioformate
audio_endungen = (".m4a", ".mp3", ".wav", ".aac", ".ogg", ".flac", ".amr", ".opus")
Ausgabeordner für Transkripte
os.makedirs("transkripte", exist_ok=True)
for dateiname in os.listdir(audio_verzeichnis):
if dateiname.lower().endswith(audio_endungen):
dateipfad = os.path.join(audio_verzeichnis, dateiname)
with open(dateipfad, "rb") as f:
print(f"Transkribiere: {dateiname}")
ergebnis = openai.Audio.transcribe(
model="whisper-1",
file=f,
response_format="text"
)
ausgabe_pfad = os.path.join("transkripte", f"{dateiname}.txt")
with open(ausgabe_pfad, "w", encoding="utf-8") as out:
out.write(ergebnis)
print(f"Gespeichert: {ausgabe_pfad}")
Beta Was this translation helpful? Give feedback.
All reactions