#!/usr/bin/env python3
"""
Streamlit app with embedded WebSocket server for VoiceCal WebRTC
Single-service approach for HuggingFace Spaces compatibility
"""
import streamlit as st
import asyncio
import threading
import json
import sys
from datetime import datetime
import os
# Configure Streamlit page
st.set_page_config(
page_title="VoiceCal - Voice Assistant",
page_icon="đ¤",
layout="wide"
)
def main():
st.title("đ¤đ
VoiceCal - Voice-Enabled AI Assistant")
st.markdown("**WebRTC Voice Integration Following unmute.sh Pattern**")
# Service status dashboard
col1, col2, col3 = st.columns(3)
with col1:
st.metric("đ¤ VoiceCal", "Online", "â
")
st.metric("đĄ WebSocket", "Embedded", "đ§")
with col2:
st.metric("đ§ STT Service", "Ready", "â
")
st.metric("đ TTS Service", "Ready", "â
")
with col3:
st.metric("đ Connection", "Direct", "âĄ")
st.metric("đą Pattern", "unmute.sh", "đ¯")
# Connection Status
st.success("đ¯ **STT Service Connected**: `wss://pgits-stt-gpu-service.hf.space/ws/stt`")
# WebRTC Integration Section
st.markdown("---")
st.header("đ WebRTC Voice Interface")
# Simplified WebRTC interface that connects directly to STT service
webrtc_html = """
đ¤ Voice Interface (Direct STT Connection)
Status: Ready to connect to STT service...
Transcription: Ready for voice input...
"""
# Render the WebRTC interface
st.components.v1.html(webrtc_html, height=500)
# Technical Information
st.markdown("---")
st.header("đ§ Technical Details")
col1, col2 = st.columns(2)
with col1:
st.subheader("đĄ WebSocket Connection")
st.code("""
STT WebSocket: wss://pgits-stt-gpu-service.hf.space/ws/stt
Audio Format: WebM/Opus (16kHz, Mono)
Service: Standalone STT v1.0.0
Pattern: unmute.sh methodology
Connection: Pure WebSocket (no fallbacks)
""")
with col2:
st.subheader("đ¯ Features")
st.write("â
Pure WebSocket STT connection")
st.write("â
WebRTC MediaRecorder integration")
st.write("â
unmute.sh audio processing")
st.write("â
Real-time voice transcription")
st.write("â
Standalone STT service v1.0.0")
st.write("â
No HTTP API fallbacks")
st.write("â
Base64 audio transmission")
# Connection Status
st.subheader("đ Service Status")
st.json({
"stt_websocket": "wss://pgits-stt-gpu-service.hf.space/ws/stt",
"stt_service": "Standalone WebSocket STT v1.0.0",
"connection_type": "pure_websocket",
"audio_format": "WebM/Opus 16kHz",
"transmission": "Base64 encoded",
"pattern": "unmute.sh WebSocket methodology",
"fallbacks": "disabled",
"status": "Ready for WebSocket voice interaction"
})
# Footer
st.markdown("---")
st.markdown("đ **VoiceCal WebSocket STT** - Pure WebSocket WebRTC with standalone STT service v1.0.0")
if __name__ == "__main__":
main()