import gradio as gr import os from dotenv import load_dotenv from PIL import Image import io import base64 import requests from datetime import datetime from pytz import timezone import numpy as np load_dotenv() # 初回訪問のメッセージ welcome_message = """
以下から選択してください。
""" # Googleフォームの送信URL apps_script_url = os.environ["APPS_SCRIPT_URL"] # ローカライズ用辞書 translations = { "en": { "welcome_message": "Please select below.
", "visit_choices": ["First time", "Returning"], "returning_message": "Click the button below to proceed.
", "proceed_button": "Proceed", "survey_title": "Fill out the form below and submit.
", "form": { "source": "1. Where did you learn about this Space?", "country": "2. Which country or region do you live in?", "ai_usage": "3. Have you used AI to generate illustrations?", "ai_usage_choices": ["Select...", "Frequently", "Sometimes", "Never"], "drawing_experience": "4. Have you practiced traditional hand-drawn illustrations?", "drawing_experience_choices": ["Select...", "As a hobby", "For work", "Never"], "issues": "5. (Optional) Tell us about any challenges you've faced while practicing illustrations.", "interest": "6. (Optional) What interested you in this Space?", "contact_info": "7. (Optional) Provide your contact information (e.g., SNS, URL, email)", "contact_info_placeholder": "e.g., Twitter, portfolio URL, email", "submit_button": "Submit" } }, "ja": { "welcome_message": "以下から選択してください。
", "visit_choices": ["初めて利用する", "2回目以降"], "returning_message": "以下のボタンをクリックして進んでください。
", "proceed_button": "進む", "survey_title": "以下のフォームに入力して送信してください。
", "form": { "source": "1. このSpaceをどこで知りましたか?", "country": "2. お住まいの国や地域を教えてください。", "ai_usage": "3. 生成AIでイラスト生成をしたことがありますか?", "ai_usage_choices": ["選択してください...", "よくする", "ある", "ない"], "drawing_experience": "4. 生成AIではない従来の手描きイラストを練習した経験はありますか?", "drawing_experience_choices": ["選択してください...", "趣味で", "仕事で", "ない"], "issues": "5. (任意)イラストの練習中に困った経験があれば教えてください", "interest": "6. (任意)このSpaceに興味を持った理由を教えてください。", "contact_info": "7. (任意)連絡先(SNS、URL、メールアドレスなど)を教えてください", "contact_info_placeholder": "例: Twitterアカウント、ポートフォリオURL、メールアドレスなど", "submit_button": "送信" } }, "zh": { "welcome_message": "请从下面选择。
", "visit_choices": ["第一次", "再次访问"], "returning_message": "请点击下面的按钮继续。
", "proceed_button": "继续", "survey_title": "填写以下表格并提交。
", "form": { "source": "1. 您是从哪里得知此服务的?", "country": "2. 您居住的国家或地区是?", "ai_usage": "3. 您是否使用过AI生成插图?", "ai_usage_choices": ["请选择...", "经常", "偶尔", "从未"], "drawing_experience": "4. 您是否练习过传统手绘插图?", "drawing_experience_choices": ["请选择...", "作为爱好", "为了工作", "从未"], "issues": "5. (可选)在练习插图过程中遇到的挑战是什么?", "interest": "6. (可选)是什么让您对这个Space感兴趣?", "contact_info": "7. (可选)提供您的联系方式(如:SNS、网址、电子邮件等)", "contact_info_placeholder": "例如:Twitter、作品集网址、电子邮件", "submit_button": "提交" } } } # 言語選択に応じてローカライズ def localize(language): t = translations[language] return { "welcome_message": t["welcome_message"], "visit_choices": t["visit_choices"], "returning_message": t["returning_message"], "proceed_button": t["proceed_button"], "form_html": f"""