VeuReu commited on
Commit
39778cd
·
1 Parent(s): aa236b2

Upload 2 files

Browse files
Files changed (1) hide show
  1. api_client.py +15 -6
api_client.py CHANGED
@@ -125,12 +125,21 @@ class APIClient:
125
  if not self.tts_url:
126
  raise ValueError("La URL del servei TTS no està configurada (API_TTS_URL)")
127
 
128
- url = f"{self.tts_url.rstrip('/')}/tts/text"
129
- data = {
130
- "texto": text,
131
- "voice": voice,
132
- "formato": "mp3"
133
- }
 
 
 
 
 
 
 
 
 
134
 
135
  try:
136
  r = requests.post(url, data=data, timeout=self.timeout)
 
125
  if not self.tts_url:
126
  raise ValueError("La URL del servei TTS no està configurada (API_TTS_URL)")
127
 
128
+ # Si el texto es largo (> 480 caracteres), usar el endpoint de texto largo
129
+ if len(text) > 480:
130
+ url = f"{self.tts_url.rstrip('/')}/tts/text_long"
131
+ data = {
132
+ "texto": text,
133
+ "voice": voice,
134
+ "formato": "mp3"
135
+ }
136
+ else:
137
+ url = f"{self.tts_url.rstrip('/')}/tts/text"
138
+ data = {
139
+ "texto": text,
140
+ "voice": voice,
141
+ "formato": "mp3"
142
+ }
143
 
144
  try:
145
  r = requests.post(url, data=data, timeout=self.timeout)