Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ st.set_page_config(page_title="AI 名片備註系統", layout="centered")
|
|
| 5 |
st.title("📇 名片辨識 + 語音備註")
|
| 6 |
st.markdown("請使用下方功能拍攝名片或錄音備註,資料將自動送出後端 API 處理")
|
| 7 |
|
|
|
|
|
|
|
| 8 |
# 上傳圖片區塊
|
| 9 |
uploaded_image = st.file_uploader("📷 上傳名片照片", type=["jpg", "jpeg", "png"])
|
| 10 |
if uploaded_image:
|
|
@@ -13,7 +15,7 @@ if uploaded_image:
|
|
| 13 |
files = {"image": uploaded_image.getvalue()}
|
| 14 |
with st.spinner("辨識中..."):
|
| 15 |
try:
|
| 16 |
-
res = requests.post("
|
| 17 |
st.success("名片辨識結果:")
|
| 18 |
st.json(res.json())
|
| 19 |
except Exception as e:
|
|
@@ -27,7 +29,7 @@ if uploaded_audio:
|
|
| 27 |
files = {"audio": uploaded_audio.getvalue()}
|
| 28 |
with st.spinner("語音辨識中..."):
|
| 29 |
try:
|
| 30 |
-
res = requests.post("
|
| 31 |
st.success("語音辨識結果:")
|
| 32 |
st.json(res.json())
|
| 33 |
except Exception as e:
|
|
|
|
| 5 |
st.title("📇 名片辨識 + 語音備註")
|
| 6 |
st.markdown("請使用下方功能拍攝名片或錄音備註,資料將自動送出後端 API 處理")
|
| 7 |
|
| 8 |
+
API_BASE = "https://f876-125-228-143-171.ngrok-free.app"
|
| 9 |
+
|
| 10 |
# 上傳圖片區塊
|
| 11 |
uploaded_image = st.file_uploader("📷 上傳名片照片", type=["jpg", "jpeg", "png"])
|
| 12 |
if uploaded_image:
|
|
|
|
| 15 |
files = {"image": uploaded_image.getvalue()}
|
| 16 |
with st.spinner("辨識中..."):
|
| 17 |
try:
|
| 18 |
+
res = requests.post(f"{API_BASE}/ocr", files=files)
|
| 19 |
st.success("名片辨識結果:")
|
| 20 |
st.json(res.json())
|
| 21 |
except Exception as e:
|
|
|
|
| 29 |
files = {"audio": uploaded_audio.getvalue()}
|
| 30 |
with st.spinner("語音辨識中..."):
|
| 31 |
try:
|
| 32 |
+
res = requests.post(f"{API_BASE}/transcribe", files=files)
|
| 33 |
st.success("語音辨識結果:")
|
| 34 |
st.json(res.json())
|
| 35 |
except Exception as e:
|