Spaces:
Running
on
Zero
Running
on
Zero
dfa
Browse files- routers/webhook.py +42 -1
routers/webhook.py
CHANGED
@@ -122,7 +122,48 @@ async def webhook(request: Request):
|
|
122 |
link_url = "https://docs.google.com/spreadsheets/d/13pqP-Ywo5eRlZBsYX2m3ChARG38EoIYOowFd3cWij1c/edit?gid=283940886#gid=283940886"
|
123 |
#test_set_lide(subtitle, text)
|
124 |
thread_name = send_google_chat_card(webhook_url, title, subtitle, link_text, link_url,thmbnail)
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
#########################################################################
|
127 |
### n8n WorkFlowStart
|
128 |
#########################################################################
|
|
|
122 |
link_url = "https://docs.google.com/spreadsheets/d/13pqP-Ywo5eRlZBsYX2m3ChARG38EoIYOowFd3cWij1c/edit?gid=283940886#gid=283940886"
|
123 |
#test_set_lide(subtitle, text)
|
124 |
thread_name = send_google_chat_card(webhook_url, title, subtitle, link_text, link_url,thmbnail)
|
125 |
+
|
126 |
+
import requests
|
127 |
+
import os
|
128 |
+
|
129 |
+
# テキストを定義
|
130 |
+
text = ("私たちは、リファスタという買取店舗を運営しています。私たちはAIですと最初にいい、間違った答えもいうとお詫びを言う。"
|
131 |
+
"会話履歴はOFFにしていることを伝えてください。間違った答えを出さない為とも伝えてください。"
|
132 |
+
"設定が必要な場合、下記からチャットで必要内容を登録してください")
|
133 |
+
|
134 |
+
# テキストをファイルに保存
|
135 |
+
text_file_path = 'text.txt'
|
136 |
+
with open(text_file_path, 'w', encoding='utf-8') as file:
|
137 |
+
file.write(text)
|
138 |
+
|
139 |
+
# 音声合成のクエリを取得
|
140 |
+
with open(text_file_path, 'r', encoding='utf-8') as file:
|
141 |
+
response = requests.post(
|
142 |
+
"https://kenken999-voicebox.hf.space/audio_query?speaker=1",
|
143 |
+
params={'text': file.read()}
|
144 |
+
)
|
145 |
+
|
146 |
+
query_json = response.json()
|
147 |
+
|
148 |
+
# 音声合成の実行
|
149 |
+
response = requests.post(
|
150 |
+
"https://kenken999-voicebox.hf.space/synthesis?speaker=2",
|
151 |
+
headers={"Content-Type": "application/json"},
|
152 |
+
json=query_json
|
153 |
+
)
|
154 |
+
|
155 |
+
# staticフォルダに音声ファイルを保存
|
156 |
+
os.makedirs('static', exist_ok=True)
|
157 |
+
audio_file_path = os.path.join('static', 'audio.wav')
|
158 |
+
with open(audio_file_path, 'wb') as file:
|
159 |
+
file.write(response.content)
|
160 |
+
|
161 |
+
print(f"Audio saved as {audio_file_path}")
|
162 |
+
wavurl = "https://kenken999-nodex-n8n.hf.space"+audio_file_path
|
163 |
+
thread_name = send_google_chat_card_thread(webhook_url, "youtub audiofile", wavurl, link_text, link_url,thread_name)
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
#########################################################################
|
168 |
### n8n WorkFlowStart
|
169 |
#########################################################################
|