Closed 401557122 closed 1 week ago
To resolve the issue where the voice selected on the web interface is not being passed into xinference and instead the default voice is always used, ensure that the selected voice is correctly passed through the entire flow from the web interface to the _invoke
method and then to _tts_invoke_streaming
.
Check the _invoke
Method:
Ensure the voice
parameter is correctly passed to the _invoke
method:
def _invoke(self, model: str, tenant_id: str, credentials: dict, content_text: str, voice: str, user: Optional[str] = None):
return self._tts_invoke_streaming(model, credentials, content_text, voice)
Check the _tts_invoke_streaming
Method:
Ensure the voice
parameter is correctly passed to the _tts_invoke_streaming
method:
def _tts_invoke_streaming(self, model: str, credentials: dict, content_text: str, voice: str) -> any:
handle = RESTfulAudioModelHandle(credentials['model_uid'], credentials['server_url'], auth_headers={})
model_support_voice = [x.get("value") for x in self.get_tts_model_voices(model=model, credentials=credentials)]
if not voice or voice not in model_support_voice:
voice = self._get_model_default_voice(model, credentials)
response = handle.speech(input=content_text.strip(), voice=voice, response_format="mp3", speed=1.0, stream=False)
for i in range(0, len(response), 1024):
yield response[i:i + 1024]
Ensure Correct Configuration:
Ensure your Dify container can access the Xinference endpoint. Use the host IP address instead of localhost
in the Dify settings:
In `Settings > Model Providers > Xinference`, enter:
* Model name: `CosyVoice`
* Server URL: `http://<Machine_IP>:9997` **Replace with your machine IP address**
* Model UID: `CosyVoice-300M-SFT`
By ensuring the voice
parameter is correctly set and passed through the system, and configuring the network settings properly, the selected voice should be used instead of the default voice [1][2].
To continue talking to Dosu, mention @dosu.
I have modified the code of the Docker API to add print ('voice '), but Docker logs do not display. Will Flask automatically load the modifications or is there any problem @dosu
Flask can automatically reload modifications if it is running in debug mode. To ensure Flask reloads your code changes in a Docker container, you need to set the DEBUG
environment variable to true
.
In your entrypoint.sh
script, Flask is run with the --debug
flag if the DEBUG
environment variable is set to true
:
if [[ "${DEBUG}" == "true" ]]; then
exec flask run --host=${DIFY_BIND_ADDRESS:-0.0.0.0} --port=${DIFY_PORT:-5001} --debug
else
exec gunicorn \
--bind "${DIFY_BIND_ADDRESS:-0.0.0.0}:${DIFY_PORT:-5001}" \
--workers ${SERVER_WORKER_AMOUNT:-1} \
--worker-class ${SERVER_WORKER_CLASS:-gevent} \
--timeout ${GUNICORN_TIMEOUT:-200} \
--preload \
app:app
fi
To enable automatic reloading, set the DEBUG
environment variable to true
in your Docker setup. You can do this by adding the following line to your .env
file:
DEBUG=true
Then, restart your Docker containers to apply the changes:
docker compose down
docker compose up -d
This should enable Flask's auto-reloading feature, and your modifications should be reflected in the Docker logs [1].
To continue talking to Dosu, mention @dosu.
Is there a performance advantage between gunicorn and debug @dosu
Yes, there is a significant performance advantage when using gunicorn
compared to running Flask in debug mode.
Concurrency and Request Handling:
Worker Management:
gevent
for asynchronous handling), improving its ability to manage and process multiple requests simultaneously.Timeouts and Preloading:
In summary, gunicorn
provides better performance, scalability, and reliability for production environments compared to Flask's debug mode [1].
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.7.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I deployed CosyVoice-300M-SFT UID and CosyVoice-300M-SFT on xinference, and configured the model name as CosyVoice. I chose voice on the web, but the voice passed into xinference has always been default
✔️ Expected Behavior
No response
❌ Actual Behavior
No response