Skip to content

Commit

Permalink
Merge pull request #53 from statgarten/ddr2
Browse files Browse the repository at this point in the history
fix : stt api
  • Loading branch information
parkdongsu authored Nov 10, 2023
2 parents f7f43f4 + 11316b0 commit b87f023
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fastapi_backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sentencepiece==0.1.99
gdown==4.7.1
fastapi==0.104.0
librosa==0.10.1
openai==0.28.1
openai==1.1.1
openpyxl==3.1.2
numpy==1.26.1
streamlit==1.28.0
Expand Down
8 changes: 5 additions & 3 deletions fastapi_backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
import soundfile as sf
import librosa
import openai

import requests
import time
Expand Down Expand Up @@ -574,8 +575,7 @@ async def transcribe_endpoint(file: UploadFile = File(...)):
return {"transcription": transcription}

@app.post("/speech_to_text_api")
async def transcribe_api_endpoint(client_id: str = Form(...),
client_secret: str = Form(...),
async def transcribe_api_endpoint(api_key: str = Form(...),
file: UploadFile = File(...)):

# Save temporary audio file
Expand Down Expand Up @@ -637,8 +637,10 @@ async def transcribe_api_endpoint(client_id: str = Form(...),
temp_file.write(audio_file)
temp_file_path = temp_file.name

# client = OpenAI()

with open(temp_file_path, 'rb') as open_audio_file:
transcription = openai.Audio.transcribe(model="whisper-1", file=open_audio_file, response_format="text", language='ko')
transcript = openai.audio.transcriptions.create(model="whisper-1", file=open_audio_file, response_format="text")

return {"transcription": transcription}
########### Speech2Text End #############
2 changes: 1 addition & 1 deletion streamlit_frontend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
openpyxl==3.1.2
openai==0.28.1
openai==1.1.1
streamlit==1.24.1
streamlit-modal==0.1.0
pandas==2.1.2
Expand Down

0 comments on commit b87f023

Please sign in to comment.