camera / streamlit_app.py
Emma1030's picture
Create streamlit_app.py
969cd12 verified
Raw History Blame Contribute Delete
1.47 kB
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}")