Spaces:
Sleeping
Sleeping
add cai ren speaker
Browse files- api.py +5 -1
- app.py +7 -1
- blog_class.py +2 -2
api.py
CHANGED
|
@@ -11,8 +11,10 @@ INFO_audio_ID_dict = {
|
|
| 11 |
"matsu": os.getenv("INFO_audio_matsu"),
|
| 12 |
"ken": os.getenv("INFO_audio_ken"),
|
| 13 |
"mana": os.getenv("INFO_audio_mana"),
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
-
|
| 16 |
|
| 17 |
client = OpenAI(api_key=os.getenv("gpt"))
|
| 18 |
#
|
|
@@ -87,6 +89,8 @@ def get_embedding(text):
|
|
| 87 |
)
|
| 88 |
def audio_text(text, audio_path, speaker_id):
|
| 89 |
# TODO change speaker
|
|
|
|
|
|
|
| 90 |
with open(audio_path, "wb") as f:
|
| 91 |
for chunk in audio_client.tts(
|
| 92 |
TTSRequest(
|
|
|
|
| 11 |
"matsu": os.getenv("INFO_audio_matsu"),
|
| 12 |
"ken": os.getenv("INFO_audio_ken"),
|
| 13 |
"mana": os.getenv("INFO_audio_mana"),
|
| 14 |
+
"cai": os.getenv("INFO_audio_cai"),
|
| 15 |
+
"ren": os.getenv("INFO_audio_ren"),
|
| 16 |
}
|
| 17 |
+
# print(INFO_audio_ID_dict)
|
| 18 |
|
| 19 |
client = OpenAI(api_key=os.getenv("gpt"))
|
| 20 |
#
|
|
|
|
| 89 |
)
|
| 90 |
def audio_text(text, audio_path, speaker_id):
|
| 91 |
# TODO change speaker
|
| 92 |
+
# print(speaker_id, ":", INFO_audio_ID_dict[speaker_id])
|
| 93 |
+
|
| 94 |
with open(audio_path, "wb") as f:
|
| 95 |
for chunk in audio_client.tts(
|
| 96 |
TTSRequest(
|
app.py
CHANGED
|
@@ -163,7 +163,13 @@ with gr.Blocks(title="勉強会", css=custom_css, head=custom_head, js=js_func)
|
|
| 163 |
with gr.Accordion("話者紹介", open=False):
|
| 164 |
gr.Markdown(speaker_text)
|
| 165 |
speaker_toggle = gr.Radio(
|
| 166 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
value="matsu",
|
| 168 |
label="話者スタイル",
|
| 169 |
)
|
|
|
|
| 163 |
with gr.Accordion("話者紹介", open=False):
|
| 164 |
gr.Markdown(speaker_text)
|
| 165 |
speaker_toggle = gr.Radio(
|
| 166 |
+
[
|
| 167 |
+
("さらとが", "matsu"),
|
| 168 |
+
("ケンシロウ", "ken"),
|
| 169 |
+
("まな", "mana"),
|
| 170 |
+
("藤井", "ren"),
|
| 171 |
+
("内山", "cai"),
|
| 172 |
+
],
|
| 173 |
value="matsu",
|
| 174 |
label="話者スタイル",
|
| 175 |
)
|
blog_class.py
CHANGED
|
@@ -141,7 +141,7 @@ class knowledge_class:
|
|
| 141 |
# get similar info
|
| 142 |
question_vector = get_embedding(question_text)[0]
|
| 143 |
info_text, info_title = self.find_top_info(question_vector, speaker_flag)
|
| 144 |
-
if speaker_flag in ["matsu"]:
|
| 145 |
user_prompt = QA_Prompt_matsu_template.format(
|
| 146 |
q_text=question_text,
|
| 147 |
r_text=info_text,
|
|
@@ -223,7 +223,7 @@ class knowledge_class:
|
|
| 223 |
# get similar info
|
| 224 |
question_vector = get_embedding(rewrite_question)[0]
|
| 225 |
info_text, info_title = self.find_top_info(question_vector, speaker_flag)
|
| 226 |
-
if speaker_flag in ["matsu"]:
|
| 227 |
user_prompt = QA_chat_Prompt_matsu_template.format(
|
| 228 |
h_text=chat_history_str,
|
| 229 |
q_text=rewrite_question,
|
|
|
|
| 141 |
# get similar info
|
| 142 |
question_vector = get_embedding(question_text)[0]
|
| 143 |
info_text, info_title = self.find_top_info(question_vector, speaker_flag)
|
| 144 |
+
if speaker_flag in ["matsu", "cai", "ren"]:
|
| 145 |
user_prompt = QA_Prompt_matsu_template.format(
|
| 146 |
q_text=question_text,
|
| 147 |
r_text=info_text,
|
|
|
|
| 223 |
# get similar info
|
| 224 |
question_vector = get_embedding(rewrite_question)[0]
|
| 225 |
info_text, info_title = self.find_top_info(question_vector, speaker_flag)
|
| 226 |
+
if speaker_flag in ["matsu", "cai", "ren"]:
|
| 227 |
user_prompt = QA_chat_Prompt_matsu_template.format(
|
| 228 |
h_text=chat_history_str,
|
| 229 |
q_text=rewrite_question,
|