File size: 1,465 Bytes
969cd12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import streamlit as st
import requests
st.set_page_config(page_title="AI 名片備註系統", layout="centered")
st.title("📇 名片辨識 + 語音備註")
st.markdown("請使用下方功能拍攝名片或錄音備註,資料將自動送出後端 API 處理")
# 上傳圖片區塊
uploaded_image = st.file_uploader("📷 上傳名片照片", type=["jpg", "jpeg", "png"])
if uploaded_image:
st.image(uploaded_image, caption="預覽名片", use_column_width=True)
if st.button("🚀 送出名片辨識"):
files = {"image": uploaded_image.getvalue()}
with st.spinner("辨識中..."):
try:
res = requests.post("https://你的-ngrok-api-url/ocr", files=files)
st.success("名片辨識結果:")
st.json(res.json())
except Exception as e:
st.error(f"辨識失敗:{e}")
# 上傳語音區塊
uploaded_audio = st.file_uploader("🎤 上傳語音備註(wav檔)", type=["wav"])
if uploaded_audio:
st.audio(uploaded_audio)
if st.button("🧠 送出語音辨識"):
files = {"audio": uploaded_audio.getvalue()}
with st.spinner("語音辨識中..."):
try:
res = requests.post("https://你的-ngrok-api-url/transcribe", files=files)
st.success("語音辨識結果:")
st.json(res.json())
except Exception as e:
st.error(f"辨識失敗:{e}")
|