ABSOLUTEUNB commited on
Commit
a43bf79
·
verified ·
1 Parent(s): 82cdef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -17
app.py CHANGED
@@ -72,7 +72,6 @@ STYLE_PROMPTS = {
72
  """
73
  }
74
 
75
- # 智能撩骚回复(支持风格选择)
76
  @GPU
77
  def smart_reply(user_input, style):
78
  prompt = STYLE_PROMPTS.get(style, STYLE_PROMPTS["sweetie"]).replace("{input}", user_input)
@@ -92,7 +91,6 @@ def smart_reply(user_input, style):
92
  print(f"生成({style}):", response)
93
  return response
94
 
95
- # 回复 + 合成语音
96
  @GPU
97
  def chat_with_natasha(message, style):
98
  reply_text = smart_reply(message, style)
@@ -104,19 +102,24 @@ def chat_with_natasha(message, style):
104
  )
105
  return reply_text, "natasha_reply.wav"
106
 
107
- # Gradio UI
108
- chat_ui = gr.Interface(
109
- fn=chat_with_natasha,
110
- inputs=[
111
- gr.Textbox(label="对 Natasha 说点什么~"),
112
- gr.Radio(choices=["sweetie", "queen", "slutty"], label="选择她的风格~", value="sweetie")
113
- ],
114
- outputs=[
115
- gr.Textbox(label="她说:"),
116
- gr.Audio(label="Natasha 的语音回应", autoplay=True)
117
- ],
118
- title="🎀 Natasha 虚拟女友:多风格调情语音版",
119
- description="输入撩人话题,选择她的个性 Natasha 用你训练的声音自动调情回答~"
120
- )
 
 
 
121
 
122
- chat_ui.launch()
 
 
 
72
  """
73
  }
74
 
 
75
  @GPU
76
  def smart_reply(user_input, style):
77
  prompt = STYLE_PROMPTS.get(style, STYLE_PROMPTS["sweetie"]).replace("{input}", user_input)
 
91
  print(f"生成({style}):", response)
92
  return response
93
 
 
94
  @GPU
95
  def chat_with_natasha(message, style):
96
  reply_text = smart_reply(message, style)
 
102
  )
103
  return reply_text, "natasha_reply.wav"
104
 
105
+ # ✅ 封装 Gradio 接口,支持 API
106
+ def build_ui():
107
+ return gr.Interface(
108
+ fn=chat_with_natasha,
109
+ inputs=[
110
+ gr.Textbox(label=" Natasha 说点什么~"),
111
+ gr.Radio(choices=["sweetie", "queen", "slutty"], label="选择她的风格~", value="sweetie")
112
+ ],
113
+ outputs=[
114
+ gr.Textbox(label="她说:"),
115
+ gr.Audio(label="Natasha 的语音回应", autoplay=True)
116
+ ],
117
+ title="🎀 Natasha 虚拟女友:多风格调情语音版",
118
+ description="输入撩人话题,选择她的个性 → Natasha 用你训练的声音自动调情回答~"
119
+ )
120
+
121
+ demo = build_ui()
122
 
123
+ # ✅ 开启 API 调用和队列
124
+ if __name__ == "__main__":
125
+ demo.launch(enable_queue=True, show_api=True)