Spaces:
Sleeping
Sleeping
revise lyric_format_prompt to include additional instructions for response brevity and relevance
Browse files
server.py
CHANGED
@@ -55,6 +55,7 @@ sample_rate = 44100
|
|
55 |
# load dataset for random_select
|
56 |
song2note_lengths, song_db = load_song_database(config)
|
57 |
|
|
|
58 |
def remove_non_chinese_japanese(text):
|
59 |
pattern = r'[^\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\u3000-\u303f\u3001\u3002\uff0c\uff0e]+'
|
60 |
cleaned = re.sub(pattern, '', text)
|
@@ -82,11 +83,12 @@ def get_lyric_format_prompts_and_metadata(config):
|
|
82 |
phrase_length, metadata = estimate_sentence_length(
|
83 |
None, config, song2note_lengths
|
84 |
)
|
85 |
-
|
86 |
-
|
87 |
-
+ [f"\n第{i}句:{c}个字" for i, c in enumerate(phrase_length, 1)]
|
88 |
-
|
89 |
-
|
|
|
90 |
else:
|
91 |
raise ValueError(f"Unsupported melody_source: {config.melody_source}. Unable to get lyric format prompts.")
|
92 |
|
|
|
55 |
# load dataset for random_select
|
56 |
song2note_lengths, song_db = load_song_database(config)
|
57 |
|
58 |
+
|
59 |
def remove_non_chinese_japanese(text):
|
60 |
pattern = r'[^\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\u3000-\u303f\u3001\u3002\uff0c\uff0e]+'
|
61 |
cleaned = re.sub(pattern, '', text)
|
|
|
83 |
phrase_length, metadata = estimate_sentence_length(
|
84 |
None, config, song2note_lengths
|
85 |
)
|
86 |
+
lyric_format_prompt = (
|
87 |
+
"\n请按照歌词格式回答我的问题,每句需遵循以下字数规则:"
|
88 |
+
+ "".join(+[f"\n第{i}句:{c}个字" for i, c in enumerate(phrase_length, 1)])
|
89 |
+
+ "\n如果没有足够的信息回答,请使用最少的句子,不要重复、不要扩展、不要加入无关内容。\n"
|
90 |
+
)
|
91 |
+
return lyric_format_prompt, metadata
|
92 |
else:
|
93 |
raise ValueError(f"Unsupported melody_source: {config.melody_source}. Unable to get lyric format prompts.")
|
94 |
|