feat(solaris): navalil dobrenko
This commit is contained in:
@@ -4,18 +4,19 @@ from google import genai
|
||||
from google.genai import types
|
||||
from pydub import AudioSegment
|
||||
|
||||
from ..content_configs import TTS_CONTENT_CONFIG
|
||||
from ..content_configs import generate_tts_config
|
||||
|
||||
TTS_MODEL = "gemini-2.5-flash-preview-tts"
|
||||
|
||||
|
||||
class TTSAgent:
|
||||
def __init__(self, api_key: str) -> None:
|
||||
self.client = genai.Client(api_key=api_key).aio
|
||||
def __init__(self, client: genai.client.AsyncClient) -> None:
|
||||
self.client = client
|
||||
self.content_config = generate_tts_config()
|
||||
|
||||
async def generate(self, text: str):
|
||||
response = await self.client.models.generate_content(
|
||||
model="gemini-2.5-flash-preview-tts",
|
||||
contents=text,
|
||||
config=TTS_CONTENT_CONFIG,
|
||||
model=TTS_MODEL, contents=text, config=self.content_config
|
||||
)
|
||||
data = response.candidates[0].content.parts[0].inline_data.data
|
||||
pcm_io = io.BytesIO(data)
|
||||
|
||||
Reference in New Issue
Block a user