|
@@ -11,7 +11,7 @@ from dashscope.audio.tts import ResultCallback, SpeechSynthesizer, SpeechSynthes
|
|
|
|
|
|
|
|
import requests
|
|
import requests
|
|
|
|
|
|
|
|
-from ..schemas.speech import TextToSpeechResponse
|
|
|
|
|
|
|
+from ..schemas.speech import TextToSpeechResponse, DataPayload
|
|
|
from ..core.config import get_settings
|
|
from ..core.config import get_settings
|
|
|
|
|
|
|
|
settings = get_settings()
|
|
settings = get_settings()
|
|
@@ -74,11 +74,15 @@ class SpeechProvider:
|
|
|
Path(out_path).unlink(missing_ok=True)
|
|
Path(out_path).unlink(missing_ok=True)
|
|
|
except Exception as del_err:
|
|
except Exception as del_err:
|
|
|
print(f"[warn] Failed to delete local audio {out_path}: {del_err}")
|
|
print(f"[warn] Failed to delete local audio {out_path}: {del_err}")
|
|
|
- return TextToSpeechResponse(audio_url=url)
|
|
|
|
|
|
|
+ return TextToSpeechResponse(
|
|
|
|
|
+ code=0,
|
|
|
|
|
+ data=DataPayload(audio_url=url),
|
|
|
|
|
+ msg='success'
|
|
|
|
|
+ )
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
# If upload fails, fall back to local path to avoid breaking
|
|
# If upload fails, fall back to local path to avoid breaking
|
|
|
print(f"[warn] Upload failed: {e}")
|
|
print(f"[warn] Upload failed: {e}")
|
|
|
- return TextToSpeechResponse(audio_url=str(out_path))
|
|
|
|
|
|
|
+ return TextToSpeechResponse(code=0, msg=e.message/'error')
|
|
|
|
|
|
|
|
|
|
|
|
|
class Callback(ResultCallback):
|
|
class Callback(ResultCallback):
|