Spaces:
Running
Running
admin
commited on
Commit
·
cf4ccbb
1
Parent(s):
7d2b9c2
2 en
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ def infer(
|
|
35 |
out_json="./content.json",
|
36 |
):
|
37 |
if not bgm:
|
38 |
-
return None, "
|
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, "
|
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, "
|
65 |
|
66 |
|
67 |
if __name__ == "__main__":
|
@@ -70,38 +70,38 @@ if __name__ == "__main__":
|
|
70 |
fn=infer,
|
71 |
inputs=[
|
72 |
gr.Textbox(
|
73 |
-
label="
|
74 |
-
placeholder="
|
75 |
),
|
76 |
gr.Textbox(
|
77 |
-
label="
|
78 |
-
placeholder="
|
79 |
),
|
80 |
gr.Textbox(
|
81 |
-
label="
|
82 |
-
placeholder="
|
83 |
),
|
84 |
gr.Textbox(
|
85 |
-
label="
|
86 |
-
placeholder="
|
87 |
),
|
88 |
gr.TextArea(
|
89 |
-
label="
|
90 |
-
placeholder="
|
91 |
),
|
92 |
gr.Textbox(
|
93 |
-
label="
|
94 |
-
placeholder="
|
95 |
),
|
96 |
gr.Audio(
|
97 |
-
label="
|
98 |
type="filepath",
|
99 |
format="mp3",
|
100 |
),
|
101 |
],
|
102 |
outputs=[
|
103 |
-
gr.File(label="
|
104 |
-
gr.Textbox(label="
|
105 |
],
|
106 |
examples=[
|
107 |
[
|
@@ -114,14 +114,12 @@ if __name__ == "__main__":
|
|
114 |
"./example.mp3",
|
115 |
]
|
116 |
],
|
117 |
-
title="
|
118 |
-
submit_btn="
|
119 |
-
clear_btn="
|
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 |
|