admin commited on
Commit
cf4ccbb
·
1 Parent(s): 7d2b9c2
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -35,7 +35,7 @@ def infer(
35
  out_json="./content.json",
36
  ):
37
  if not bgm:
38
- return None, "请上传背景音乐 (Please upload a BGM)"
39
 
40
  if os.path.exists(out_json):
41
  os.remove(out_json)
@@ -51,7 +51,7 @@ def infer(
51
  }
52
 
53
  if not content["bgm"]:
54
- return None, "上传的 BGM 过大 (Your uploaded BGM is too large)"
55
 
56
  with open(out_json, "w", encoding="utf-8") as json_file:
57
  json.dump(
@@ -61,7 +61,7 @@ def infer(
61
  indent=4,
62
  )
63
 
64
- return out_json, "生成成功 (Generation success)"
65
 
66
 
67
  if __name__ == "__main__":
@@ -70,38 +70,38 @@ if __name__ == "__main__":
70
  fn=infer,
71
  inputs=[
72
  gr.Textbox(
73
- label="收信人 (Recipient)",
74
- placeholder="信封正面中心人名 (The recipient centered on front of the envelope)",
75
  ),
76
  gr.Textbox(
77
- label="发信人 (Sender)",
78
- placeholder="信封背面落款人名 (The sender name on back of the envelope)",
79
  ),
80
  gr.Textbox(
81
- label="称呼 (Salutation)",
82
- placeholder="信纸左上角称呼 (The salutation in letter's upper left corner)",
83
  ),
84
  gr.Textbox(
85
- label="落款 (Signature)",
86
- placeholder="信纸右下角落款 (The signature in letter's lower right corner)",
87
  ),
88
  gr.TextArea(
89
- label="正文 (Body)",
90
- placeholder="信纸上的正文,<br>代表换行,^后的数字代表打字机特效停顿毫秒数\n\nBody of the letter, <br> represents a line break and the number after ^ represents the number of milliseconds that the typewriter's effects pause",
91
  ),
92
  gr.Textbox(
93
- label="标题 (Title)",
94
- placeholder="浏览器标签文本 (Browser tab text)",
95
  ),
96
  gr.Audio(
97
- label="背景音乐 (BGM)",
98
  type="filepath",
99
  format="mp3",
100
  ),
101
  ],
102
  outputs=[
103
- gr.File(label="下载 JSON 文件 (Download JSON file)"),
104
- gr.Textbox(label="状态栏 (Status bar)"),
105
  ],
106
  examples=[
107
  [
@@ -114,14 +114,12 @@ if __name__ == "__main__":
114
  "./example.mp3",
115
  ]
116
  ],
117
- title="表白信封自定义配置工具 (eLuvLetter JSON Generator)",
118
- submit_btn="生成 Generate",
119
- clear_btn="清空 Clear",
120
  flagging_mode="never",
121
  cache_examples=False,
122
  description="""
123
- 本工具可为你生成自定义版 content.json 用于替换你复刻得到的 <a href='https://github.com/Society-Genius/eLuvLetter' target='_blank'>eLuvLetter</a> 仓库内的 font/content.json, 其中的背景音乐控件用于上传拆信封时所播放的音频,建议不要太大,请确保音频上传完整后再点击生成按钮。
124
-
125
  This tool can generate your customized content.json to replace the font/content.json in your forked <a href='https://github.com/Society-Genius/eLuvLetter' target='_blank'>eLuvLetter</a> repository, in which the BGM widget is used to upload the audio played when opening the envelope, it is recommended not to be too large, please make sure the audio is completely uploaded before clicking the Generate button.""",
126
  )
127
 
 
35
  out_json="./content.json",
36
  ):
37
  if not bgm:
38
+ return None, "Please upload a BGM"
39
 
40
  if os.path.exists(out_json):
41
  os.remove(out_json)
 
51
  }
52
 
53
  if not content["bgm"]:
54
+ return None, "Your uploaded BGM is too large"
55
 
56
  with open(out_json, "w", encoding="utf-8") as json_file:
57
  json.dump(
 
61
  indent=4,
62
  )
63
 
64
+ return out_json, "Generation success"
65
 
66
 
67
  if __name__ == "__main__":
 
70
  fn=infer,
71
  inputs=[
72
  gr.Textbox(
73
+ label="Recipient",
74
+ placeholder="The recipient centered on front of the envelope",
75
  ),
76
  gr.Textbox(
77
+ label="Sender",
78
+ placeholder="The sender name on back of the envelope",
79
  ),
80
  gr.Textbox(
81
+ label="Salutation",
82
+ placeholder="The salutation in letter's upper left corner",
83
  ),
84
  gr.Textbox(
85
+ label="Signature",
86
+ placeholder="The signature in letter's lower right corner",
87
  ),
88
  gr.TextArea(
89
+ label="Body",
90
+ placeholder="Body of the letter, <br> represents a line break and the number after ^ represents the number of milliseconds that the typewriter's effects pause",
91
  ),
92
  gr.Textbox(
93
+ label="Title",
94
+ placeholder="Browser tab text",
95
  ),
96
  gr.Audio(
97
+ label="BGM",
98
  type="filepath",
99
  format="mp3",
100
  ),
101
  ],
102
  outputs=[
103
+ gr.File(label="Download JSON file"),
104
+ gr.Textbox(label="Status bar"),
105
  ],
106
  examples=[
107
  [
 
114
  "./example.mp3",
115
  ]
116
  ],
117
+ title="eLuvLetter JSON Generator",
118
+ submit_btn="Generate",
119
+ clear_btn="Clear",
120
  flagging_mode="never",
121
  cache_examples=False,
122
  description="""
 
 
123
  This tool can generate your customized content.json to replace the font/content.json in your forked <a href='https://github.com/Society-Genius/eLuvLetter' target='_blank'>eLuvLetter</a> repository, in which the BGM widget is used to upload the audio played when opening the envelope, it is recommended not to be too large, please make sure the audio is completely uploaded before clicking the Generate button.""",
124
  )
125