coqui-ai / TTS

🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
http://coqui.ai
Mozilla Public License 2.0
34.7k stars 4.21k forks source link

[Bug] occur a reference error when using it with flask_socketio #3856

Open xulsup opened 2 months ago

xulsup commented 2 months ago

Describe the bug

When I import TTS module to my app.py(see the reproduce code), It will occur a reference error. When I don't import the TTS module, it can work well. I just want to use the flask_socketio to build a service to convert text to speech.

To Reproduce

the minimal reproducible code

from flask import Flask
from flask_socketio import SocketIO
import logging
from TTS.api import TTS

def create_app():
    app = Flask(__name__)
    return app

app = create_app()
socketio = SocketIO(
    app,
    path="/socket.io",
    cors_allowed_origins="*",
    logger=True,
    engineio_logger=True,
)

if __name__ == "__main__":
    host = "0.0.0.0"
    port = 8172
    app.logger.info(f"server listen on http://{host}:{port}")
    socketio.run(app, host, port, debug=True)
  1. run this code
  2. you can see the error image

requirements.txt

Flask==3.0.3
Requests==2.32.3
gevent==24.2.1
Flask-SocketIO==5.3.6
gevent-websocket==0.10.1
TTS==0.22.0

Expected behavior

No error. It can run successful.

Logs

No response

Environment

- 🐸TTS Version (e.g., 1.3.0): 0.22.0
- PyTorch Version (e.g., 1.8): 2.4.0
- Python version: 3.9.19
- OS (e.g., Linux): Mac OS 14.5
- CUDA/cuDNN version: 
- GPU models and configuration: 
- How you installed PyTorch (`conda`, `pip`, source): pip
- Any other relevant information:

the JSON by collect_env_info.py

{
    "CUDA": {
        "GPU": [],
        "available": false,
        "version": null
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.4.0",
        "TTS": "0.22.0",
        "numpy": "1.22.0"
    },
    "System": {
        "OS": "Darwin",
        "architecture": [
            "64bit",
            ""
        ],
        "processor": "arm",
        "python": "3.9.19",
        "version": "Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000"
    }
}

Additional context

No response

stale[bot] commented 4 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.