cdcd72 / gpt-ai-translator

Using Flask, OpenAI whisper API, GPT4o API to develop line bot translator.
MIT License
0 stars 1 forks source link

語音輸出 #6

Closed cdcd72 closed 1 year ago

cdcd72 commented 1 year ago

是不是有機會可以選擇要文字輸出或者語音輸出?

cdcd72 commented 1 year ago
cdcd72 commented 1 year ago
import librosa
from gtts import gTTS

audio_path = ".\sample.m4a"

# Where <lang> is an IETF language tag such as en or zh-TW, and <name> is the full English name of the language, such as English or Chinese (Mandarin/Taiwan).
tts = gTTS("トイレはどこですか?", lang="ja")
tts.save(audio_path)

audio_duration = librosa.get_duration(path=audio_path)
print(audio_duration)
cdcd72 commented 1 year ago

可能要自架一個物件儲存服務,才能達成需求。

cdcd72 commented 1 year ago

初步實作一版。

  1. librosa 會導致超出 Vercel Serverless Function Size,故暫時不計算音訊持訊時間。
  2. 接續第 1 點,故現階段會在部署的時候決定音訊持訊時間。