Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- READ.md.txt +3 -0
- api.gitignore +2 -0
- api_key.py +1 -0
- app.py +37 -0
- requirements.txt +2 -0
READ.md.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gradio Tamil Transcription
|
| 2 |
+
|
| 3 |
+
This is a Gradio app for transcribing speech in Tamil using OpenAI's API.
|
api.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
api_key.py
|
| 2 |
+
|
api_key.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
api_key =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
|
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import os
|
| 4 |
+
from api_key import api_key
|
| 5 |
+
|
| 6 |
+
# Set up your OpenAI API key
|
| 7 |
+
openai.api_key = api_key
|
| 8 |
+
|
| 9 |
+
def transcribe_audio(file_path):
|
| 10 |
+
# Open the wav file
|
| 11 |
+
with open(file_path, 'rb') as audio_file:
|
| 12 |
+
response = openai.Audio.transcribe(
|
| 13 |
+
model="whisper-1", # specify the appropriate model for transcription
|
| 14 |
+
file=audio_file,
|
| 15 |
+
language='ta' # specify 'ta' for Tamil language
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# Extract the transcription text
|
| 19 |
+
transcription_text = response['text']
|
| 20 |
+
return transcription_text
|
| 21 |
+
|
| 22 |
+
def transcribe_and_display(audio_path):
|
| 23 |
+
# Transcribe the audio file
|
| 24 |
+
transcription = transcribe_audio(audio_path)
|
| 25 |
+
return transcription
|
| 26 |
+
|
| 27 |
+
# Gradio interface
|
| 28 |
+
iface = gr.Interface(
|
| 29 |
+
fn=transcribe_and_display,
|
| 30 |
+
inputs=gr.Audio(type="filepath"),
|
| 31 |
+
outputs="text",
|
| 32 |
+
title="Speech to Text",
|
| 33 |
+
description="Upload a WAV file to transcribe speech to Tamil text."
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
# Launch the interface
|
| 37 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
openai
|