zziang commited on
Commit
b40601f
·
verified ·
1 Parent(s): 121bd04

whisper slot a09 from buy1take2; radio cast updated

Browse files
Files changed (1) hide show
  1. kaggle/radio_demo.py +8 -5
kaggle/radio_demo.py CHANGED
@@ -37,8 +37,8 @@ STEPS = 4
37
  GAP_S = 0.7
38
  SR = 44100
39
 
40
- SCRIPT_LLM = os.environ.get("SCRIPT_LLM", "Qwen/Qwen2.5-0.5B-Instruct")
41
- CAST = {"叙述": "a08", "故事": "a08", "耳语": "a01", "开场": "a05", "收尾": "a08"}
42
 
43
  FALLBACK = [
44
  {"style": "开场", "text": "晚上好,这里是深夜频道,我是今晚陪你的人。"},
@@ -70,8 +70,9 @@ def write_script() -> tuple[list[dict], str]:
70
  from transformers import AutoModelForCausalLM, AutoTokenizer
71
 
72
  prompt = (
73
- "你是一个深夜电台的编剧。写一段约 60 秒的节目串词,共 6 句,每句 8 到 28 个字。\n"
74
- "要求:前两句是正常叙述,中间讲一小段故事,最后两句逐渐转为耳语,收在很轻的一句上。\n"
 
75
  "只输出 JSON 数组,不要任何解释、不要代码块标记。格式:\n"
76
  '[{"style":"开场","text":"..."},{"style":"叙述","text":"..."},'
77
  '{"style":"故事","text":"..."},{"style":"耳语","text":"..."}]\n'
@@ -95,7 +96,9 @@ def write_script() -> tuple[list[dict], str]:
95
  m = re.search(r"\[.*\]", raw, re.S)
96
  rows = json.loads(m.group(0) if m else raw)
97
  rows = [r for r in rows if isinstance(r, dict) and r.get("text")]
98
- if len(rows) >= 4:
 
 
99
  return rows[:8], "llm"
100
  except Exception:
101
  log("script LLM failed\n" + traceback.format_exc())
 
37
  GAP_S = 0.7
38
  SR = 44100
39
 
40
+ SCRIPT_LLM = os.environ.get("SCRIPT_LLM", "Qwen/Qwen2.5-1.5B-Instruct")
41
+ CAST = {"叙述": "a08", "故事": "a08", "耳语": "a09", "开场": "a05", "收尾": "a08"}
42
 
43
  FALLBACK = [
44
  {"style": "开场", "text": "晚上好,这里是深夜频道,我是今晚陪你的人。"},
 
70
  from transformers import AutoModelForCausalLM, AutoTokenizer
71
 
72
  prompt = (
73
+ "你是一个深夜电台的编剧。写一段约 60 秒的节目串词。\n"
74
+ "硬性要求:必须正好 6 句;每句 8 到 28 个字;其中最后两句的 style 必须是「耳语」;"
75
+ "整段要收在很轻的一句上。\n"
76
  "只输出 JSON 数组,不要任何解释、不要代码块标记。格式:\n"
77
  '[{"style":"开场","text":"..."},{"style":"叙述","text":"..."},'
78
  '{"style":"故事","text":"..."},{"style":"耳语","text":"..."}]\n'
 
96
  m = re.search(r"\[.*\]", raw, re.S)
97
  rows = json.loads(m.group(0) if m else raw)
98
  rows = [r for r in rows if isinstance(r, dict) and r.get("text")]
99
+ # Three usable lines is a valid answer; the previous >=4 gate rejected a
100
+ # correct three-line script and silently used the fallback.
101
+ if len(rows) >= 3:
102
  return rows[:8], "llm"
103
  except Exception:
104
  log("script LLM failed\n" + traceback.format_exc())