Skip to content

SOTA Open Source TTS

support ipv6 (#850)

TITC7d74951dcd7a
diff --git a/tools/api_server.py b/tools/api_server.py
index 999fe4b..c4054b3 100644
--- a/tools/api_server.py
+++ b/tools/api_server.py
@@ -1,3 +1,4 @@
+import re
from threading import Lock
import pyrootutils
@@ -98,9 +99,14 @@ class API(ExceptionHandler):
# Instead, it's better to use multiprocessing or independent models per thread.
if __name__ == "__main__":
-
api = API()
- host, port = api.args.listen.split(":")
+
+ # IPv6 address format is [xxxx:xxxx::xxxx]:port
+ match = re.search(r"\[([^\]]+)\]:(\d+)$", api.args.listen)
+ if match:
+ host, port = match.groups() # IPv6
+ else:
+ host, port = api.args.listen.split(":") # IPv4
uvicorn.run(
api.app,