Spaces:
Runtime error
Runtime error
Download utils.py from Shweta7171/GenAISpeech-TextTranscriber: direct link, hf CLI and curl.
- Browser
- Download file 438 Bytes
-
https://huggingface.co/spaces/Shweta7171/GenAISpeech-TextTranscriber/resolve/main/utils.py
- Command line
-
hf download hf://spaces/Shweta7171/GenAISpeech-TextTranscriber/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/Shweta7171/GenAISpeech-TextTranscriber/resolve/main/utils.py
438 Bytes
| import os | |
| from openai import OpenAI | |
| def audio_to_text(audio_data): | |
| client = OpenAI() | |
| transcription = client.audio.transcriptions.create( | |
| model="whisper-1", | |
| file=audio_data, | |
| response_format="text" | |
| ) | |
| return transcription | |
| def text_to_speech(text): | |
| client = OpenAI() | |
| response = client.audio.speech.create( | |
| model="tts-1", | |
| voice="shimmer", | |
| input=text | |
| ) | |
| return response | |