Update app.py
Browse files
app.py
CHANGED
|
@@ -7,9 +7,11 @@ def generate_artwork(description, style, enhance_details, audio_file):
|
|
| 7 |
# 如果上传了音频文件,进行语音转文本
|
| 8 |
if audio_file is not None:
|
| 9 |
description = transcribe_audio(audio_file)
|
|
|
|
| 10 |
|
| 11 |
# 生成提示词
|
| 12 |
prompt = generate_prompt(description)
|
|
|
|
| 13 |
|
| 14 |
# 如果选中了增强细节的选项,修改提示
|
| 15 |
if enhance_details:
|
|
@@ -25,6 +27,7 @@ def generate_artwork(description, style, enhance_details, audio_file):
|
|
| 25 |
|
| 26 |
# 生成图像
|
| 27 |
image = generate_image(prompt)
|
|
|
|
| 28 |
return prompt, image
|
| 29 |
|
| 30 |
# 创建 Gradio 界面
|
|
@@ -33,7 +36,7 @@ with gr.Blocks() as demo:
|
|
| 33 |
description_input = gr.Textbox(label="请输入描述", placeholder="例如:天空中的魔法树屋")
|
| 34 |
style_selector = gr.Dropdown(choices=["奇幻", "赛博朋克", "现实主义"], label="选择风格")
|
| 35 |
detail_checkbox = gr.Checkbox(label="增强细节")
|
| 36 |
-
audio_input = gr.Audio(
|
| 37 |
|
| 38 |
with gr.Row():
|
| 39 |
output_prompt = gr.Textbox(label="生成的提示词", interactive=False)
|
|
@@ -48,3 +51,4 @@ demo.launch()
|
|
| 48 |
|
| 49 |
|
| 50 |
|
|
|
|
|
|
| 7 |
# 如果上传了音频文件,进行语音转文本
|
| 8 |
if audio_file is not None:
|
| 9 |
description = transcribe_audio(audio_file)
|
| 10 |
+
print("Transcribed Description:", description) # 打印转录后的描述
|
| 11 |
|
| 12 |
# 生成提示词
|
| 13 |
prompt = generate_prompt(description)
|
| 14 |
+
print("Generated Prompt:", prompt) # 打印生成的提示词
|
| 15 |
|
| 16 |
# 如果选中了增强细节的选项,修改提示
|
| 17 |
if enhance_details:
|
|
|
|
| 27 |
|
| 28 |
# 生成图像
|
| 29 |
image = generate_image(prompt)
|
| 30 |
+
print("Image Generated:", image) # 打印生成的图像
|
| 31 |
return prompt, image
|
| 32 |
|
| 33 |
# 创建 Gradio 界面
|
|
|
|
| 36 |
description_input = gr.Textbox(label="请输入描述", placeholder="例如:天空中的魔法树屋")
|
| 37 |
style_selector = gr.Dropdown(choices=["奇幻", "赛博朋克", "现实主义"], label="选择风格")
|
| 38 |
detail_checkbox = gr.Checkbox(label="增强细节")
|
| 39 |
+
audio_input = gr.Audio(label="录制您的描述", type="file")
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
output_prompt = gr.Textbox(label="生成的提示词", interactive=False)
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
+
|