fed8b2eed7
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Backend release / release (push) Has been cancelled
Bandit Security Scan / bandit_scan (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push multi-arch DocsGPT Docker image / manifest (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Has been cancelled
Build and push DocsGPT FE Docker image for development / manifest (push) Has been cancelled
Python linting / ruff (push) Has been cancelled
Run python tests with pytest / Run tests and count coverage (3.12) (push) Has been cancelled
React Widget Build / build (push) Has been cancelled
20 lines
461 B
Python
20 lines
461 B
Python
import io
|
|
import base64
|
|
from gtts import gTTS
|
|
from application.tts.base import BaseTTS
|
|
|
|
|
|
class GoogleTTS(BaseTTS):
|
|
def __init__(self):
|
|
pass
|
|
|
|
|
|
def text_to_speech(self, text):
|
|
lang = "en"
|
|
audio_fp = io.BytesIO()
|
|
tts = gTTS(text=text, lang=lang, slow=False)
|
|
tts.write_to_fp(audio_fp)
|
|
audio_fp.seek(0)
|
|
audio_base64 = base64.b64encode(audio_fp.read()).decode("utf-8")
|
|
return audio_base64, lang
|