MCPcopy Create free account
hub / github.com/FunAudioLLM/Fun-Audio-Chat / main

Function main

web_demo/server/server.py:1120–1158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1118 return ws
1119
1120def main():
1121 parser = argparse.ArgumentParser()
1122 parser.add_argument("--host", default="localhost", type=str)
1123 parser.add_argument("--port", default=11235, type=int)
1124 parser.add_argument("--sample-rate", default=24000, type=int, help="Audio sample rate (Opus)")
1125 parser.add_argument("--model-sample-rate", default=16000, type=int, help="Model sample rate")
1126 parser.add_argument("--output-dir", default="./output", type=str, help="Directory to save input audio files")
1127 parser.add_argument("--model-path", type=str, default="model/s2s", help="Path to S2S model")
1128 parser.add_argument("--tts-gpu", default=1, type=int, help="GPU device id for TTS model (default: 1)")
1129
1130 args = parser.parse_args()
1131
1132 log("info", f"Initializing server with Opus sample rate: {args.sample_rate}, Model sample rate: {args.model_sample_rate}")
1133
1134 model_manager = GlobalModelManager()
1135 try:
1136 model_manager.initialize(
1137 model_path=args.model_path,
1138 target_sample_rate=args.model_sample_rate
1139 )
1140 except Exception as e:
1141 log("error", f"Model initialization failed: {e}")
1142 import traceback
1143 traceback.print_exc()
1144 return
1145
1146 state = ServerState(
1147 model_manager=model_manager,
1148 sample_rate=args.sample_rate,
1149 output_dir=args.output_dir,
1150 tts_gpu=args.tts_gpu
1151 )
1152
1153 app = web.Application()
1154 app.router.add_get("/api/chat", state.handle_chat)
1155
1156 protocol = "http"
1157 log("info", f"Access the Web UI directly at {protocol}://{args.host}:{args.port}")
1158 web.run_app(app, host=args.host, port=args.port)
1159
1160if __name__ == "__main__":
1161 main()

Callers 1

server.pyFile · 0.70

Calls 4

initializeMethod · 0.95
logFunction · 0.85
GlobalModelManagerClass · 0.85
ServerStateClass · 0.85

Tested by

no test coverage detected