Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,34 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
st.set_page_config(page_title="名片
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
|
| 4 |
+
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:
|
| 11 |
+
st.image(uploaded_image, caption="預覽名片", use_column_width=True)
|
| 12 |
+
if st.button("🚀 送出名片辨識"):
|
| 13 |
+
files = {"image": uploaded_image.getvalue()}
|
| 14 |
+
with st.spinner("辨識中..."):
|
| 15 |
+
try:
|
| 16 |
+
res = requests.post("https://你的-ngrok-api-url/ocr", files=files)
|
| 17 |
+
st.success("名片辨識結果:")
|
| 18 |
+
st.json(res.json())
|
| 19 |
+
except Exception as e:
|
| 20 |
+
st.error(f"辨識失敗:{e}")
|
| 21 |
|
| 22 |
+
# 上傳語音區塊
|
| 23 |
+
uploaded_audio = st.file_uploader("🎤 上傳語音備註(wav檔)", type=["wav"])
|
| 24 |
+
if uploaded_audio:
|
| 25 |
+
st.audio(uploaded_audio)
|
| 26 |
+
if st.button("🧠 送出語音辨識"):
|
| 27 |
+
files = {"audio": uploaded_audio.getvalue()}
|
| 28 |
+
with st.spinner("語音辨識中..."):
|
| 29 |
+
try:
|
| 30 |
+
res = requests.post("https://你的-ngrok-api-url/transcribe", files=files)
|
| 31 |
+
st.success("語音辨識結果:")
|
| 32 |
+
st.json(res.json())
|
| 33 |
+
except Exception as e:
|
| 34 |
+
st.error(f"辨識失敗:{e}")
|