发布于 2026-01-06 2 阅读
0

🎤 为无声者发声 - 让无声者也能理解和交流 🔊 为无声者发声:实时语音转录助力无障碍访问 VoiceAccess - 实时语音转录助力无障碍访问 DEV 全球展示挑战赛,由 Mux 呈现:展示你的项目!

🎤 为无声者发声 - 让无声者也能理解和交流 🔊

无声者的声音:面向无障碍的实时语音转录

VoiceAccess - 实时语音转录辅助功能

由 Mux 主办的 DEV 全球展示挑战赛:展示你的项目!

这是参加AssemblyAI 语音代理挑战赛的作品。

无声者的声音:面向无障碍的实时语音转录

这是参加AssemblyAI 语音代理挑战赛的作品。

目录

我建造的

项目概述

Voice of Voiceless是一款基于 Streamlit 的尖端应用程序,旨在通过超快速的实时语音转录、情绪音调检测和情感分析,弥合聋人和听力障碍人士之间的沟通鸿沟。该应用程序专为 AssemblyAI 语音代理挑战赛而开发,展示了 300 毫秒以下语音处理速度在对无障碍访问要求极高的场景中的巨大潜力。

该应用程序不仅仅是一个转录工具,它还是一个全面的沟通助手,不仅提供关于所说内容的视觉反馈,还提供关于如何说话的视觉反馈,从而为听不到声音提示的用户创造更丰富的对话理解。

挑战类别

本次提交的作品针对实时语音性能类别,重点关注以下方面:

  • 实现始终低于 300 毫秒的转录延迟
  • 针对速度至关重要的无障碍访问场景进行优化
  • 展现实时音频处理方面的卓越技术
  • 为通信无障碍创建创新的速度相关应用程序

主要特点

该应用程序提供了一套全面的、以辅助功能为中心的特性:

  • 超快速转录:使用 AssemblyAI 的通用流媒体 API,延迟低于 300 毫秒
  • 支持多说话人:实时说话人识别和视觉区分
  • 情商:实时语调识别(快乐、悲伤、愤怒、平静、兴奋、中性)
  • 情感分析:实时情感评分及可视化指标
  • 无障碍优先设计:符合 WCAG 2.1 AA 标准的界面,具有高对比度模式
  • 性能监控:实时延迟跟踪和系统优化
  • 视觉警报系统:重要音频事件的闪光通知
  • 自适应界面:可自定义文本大小、配色方案和辅助功能偏好

演示

在线应用

“无声者之声”应用程序可使用 Streamlit 在本地运行。该界面提供直观、注重无障碍的用户体验,并具备实时更新和全面的视觉反馈系统。

屏幕截图

主界面 - 实时转录
主界面采用简洁、高对比度的设计,配有大而易读的文本和清晰的连接状态和性能指标视觉指示器。

辅助功能控制面板
侧边栏提供全面的辅助功能控制选项,包括:

  • 高对比度模式切换
  • 可缩放文本大小调整(12-28像素)
  • 视觉警报偏好
  • 音频质量设置
  • 性能监控选项

情感和语气分析:
实时显示情绪智能,包括:

  • 颜色编码的情绪指标(正面/负面/中性)
  • 基于表情符号的语气表达
  • 所有分析的置信度评分
  • 历史趋势可视化

性能仪表盘
实时显示性能指标:

  • 当前转录延迟
  • 系统资源利用率
  • 连接稳定性指标
  • 准确度测量

视频演示

该应用程序演示了几个关键场景:

  1. 实时对话转录:支持多位说话人自动识别
  2. 辅助功能展示:高对比度模式、大字体、视觉提示
  3. 性能优化:在各种条件下均实现了低于 300 毫秒的延迟
  4. 错误恢复:自动重新连接和优雅降级
  5. 多模态反馈:同时进行文本、情感和语气分析

GitHub 仓库

GitHub 标志 mohamednizzad /无声之声

VoiceOfVoiceless:面向无障碍用户的实时语音转录

VoiceAccess - 实时语音转录辅助功能

VoiceAccess 屏幕截图

🏆 AssemblyAI 语音代理挑战赛参赛作品 - 实时语音性能类别

VoiceAccess 是一款基于 Streamlit 的尖端应用程序,旨在通过提供超快速的实时语音转录、音调检测和情感分析来帮助聋人和听力障碍人士。它采用 AssemblyAI 的通用流式 API 构建,可为关键的辅助功能应用提供低于 300 毫秒的延迟。

Python 3.8+ AssemblyAI Streamlit 许可证:MIT

🎯 挑战类别:实时语音表演

本项目致力于利用 AssemblyAI 的通用流媒体技术,打造速度最快、响应最灵敏的语音体验。该技术专为对可访问性要求极高的用例而设计,在这些用例中,低于 300 毫秒的延迟至关重要。

✨ K

🎭 高级音频智能

  • 语调检测:实时情绪语调分析(快乐、悲伤、愤怒、平静等)
  • 情感分析:实时情感评分及可视化指标
  • 说话人分割:自动说话人识别和分离
  • 置信度评分:所有音频智能功能的可靠性指标

♿ 无障碍优先设计

  • 高对比度模式:增强视力障碍用户的可视性
  • 可伸缩文本

完整的源代码以及详尽的文档、安装指南和示例配置均已提供。该代码库包含:

  • 包含模块化架构的完整应用程序源代码
  • 适用于 Windows 的安装脚本
  • 完整的文档和设置指南
  • 性能测试工具
  • 无障碍合规性验证工具

技术实施与 AssemblyAI 集成

架构概述

Voice of Voiceless 采用复杂的多线程架构,旨在实现最佳的实时性能:

# Core application structure
class VoiceAccessApp:
    def __init__(self):
        self.audio_processor = AudioProcessor()
        self.transcription_service = TranscriptionService()
        self.ui_components = UIComponents()
        self.accessibility = AccessibilityFeatures()
        self.performance_monitor = PerformanceMonitor()
Enter fullscreen mode Exit fullscreen mode

该应用程序将功能划分为五个主要模块:

  • 音频处理:实时音频采集和预处理
  • 转录服务:AssemblyAI 通用流媒体集成
  • UI 组件:可访问的 Streamlit 界面组件
  • 无障碍功能:符合 WCAG 2.1 AA 标准的实现
  • 性能监控:实时指标和优化

通用流媒体集成

VoiceAccess 的核心在于它与 AssemblyAI 的通用流媒体 API 的精妙集成:

class TranscriptionService:
    def __init__(self):
        self.api_key = os.getenv('ASSEMBLYAI_API_KEY')
        aai.settings.api_key = self.api_key

        # Configure for optimal performance
        self.config = {
            'sample_rate': 16000,
            'enable_speaker_diarization': True,
            'enable_sentiment_analysis': True,
            'confidence_threshold': 0.7
        }

    def connect(self) -> bool:
        """Connect to AssemblyAI real-time transcription"""
        self.transcriber = aai.RealtimeTranscriber(
            sample_rate=self.config['sample_rate'],
            on_data=self._on_data,
            on_error=self._on_error,
        )

        self.transcriber.connect()
        return True

    def _on_data(self, transcript: aai.RealtimeTranscript):
        """Handle real-time transcription with latency tracking"""
        request_start = time.time()

        result = TranscriptionResult(
            text=transcript.text,
            confidence=getattr(transcript, 'confidence', 0.0),
            speaker=getattr(transcript, 'speaker', None),
            timestamp=datetime.now(),
            is_final=not transcript.partial
        )

        # Calculate and track latency
        latency = (time.time() - request_start) * 1000
        self.total_latency += latency

        # Trigger callbacks for UI updates
        for callback in self.callbacks:
            callback(result)
Enter fullscreen mode Exit fullscreen mode

实时音频处理

音频处理流程经过优化,在保持高品质的同时,最大限度地降低了延迟:

class AudioProcessor:
    def __init__(self, config: Optional[AudioConfig] = None):
        self.config = config or AudioConfig()
        self.audio_queue = queue.Queue(maxsize=100)

    def _audio_callback(self, indata, frames, time, status):
        """sounddevice callback optimized for low latency"""
        if status:
            logger.warning(f"Audio callback status: {status}")

        try:
            audio_bytes = indata.tobytes()

            if not self.audio_queue.full():
                self.audio_queue.put(audio_bytes, block=False)
                self.total_chunks += 1
            else:
                self.dropped_chunks += 1

        except queue.Full:
            self.dropped_chunks += 1

    def _preprocess_audio(self, audio_data: bytes) -> bytes:
        """Real-time audio preprocessing for optimal recognition"""
        audio_array = np.frombuffer(audio_data, dtype=np.int16)

        # Noise gate for clarity
        threshold = np.max(np.abs(audio_array)) * 0.1
        audio_array = np.where(np.abs(audio_array) < threshold, 0, audio_array)

        # Normalize for consistent levels
        if np.max(np.abs(audio_array)) > 0:
            audio_array = audio_array / np.max(np.abs(audio_array)) * 32767
            audio_array = audio_array.astype(np.int16)

        return audio_array.tobytes()
Enter fullscreen mode Exit fullscreen mode

音频智能功能

除了文字转录之外,VoiceAccess 还实现了先进的音频智能:

def _extract_sentiment(self, transcript) -> Dict[str, Any]:
    """Real-time sentiment analysis with confidence scoring"""
    text = transcript.text.lower()

    positive_words = ['good', 'great', 'excellent', 'happy', 'love', 'amazing']
    negative_words = ['bad', 'terrible', 'awful', 'hate', 'sad', 'angry']

    positive_count = sum(1 for word in positive_words if word in text)
    negative_count = sum(1 for word in negative_words if word in text)

    if positive_count > negative_count:
        sentiment_score = min(0.8, positive_count * 0.3)
        sentiment_label = 'positive'
    elif negative_count > positive_count:
        sentiment_score = max(-0.8, -negative_count * 0.3)
        sentiment_label = 'negative'
    else:
        sentiment_score = 0.0
        sentiment_label = 'neutral'

    return {
        'label': sentiment_label,
        'score': sentiment_score,
        'confidence': 0.75
    }

def _detect_tone(self, text: str) -> Dict[str, Any]:
    """Multi-dimensional tone detection"""
    tone_patterns = {
        'excited': ['!', 'wow', 'amazing', 'incredible', 'fantastic'],
        'calm': ['okay', 'fine', 'sure', 'alright', 'peaceful'],
        'angry': ['damn', 'hell', 'angry', 'mad', 'furious'],
        'sad': ['sad', 'depressed', 'down', 'unhappy', 'crying'],
        'happy': ['happy', 'joy', 'cheerful', 'glad', 'delighted']
    }

    tone_scores = {}
    for tone, patterns in tone_patterns.items():
        score = sum(1 for pattern in patterns if pattern in text.lower())
        tone_scores[tone] = score

    max_tone = max(tone_scores.items(), key=lambda x: x[1])

    return {
        'tone': max_tone[0] if max_tone[1] > 0 else 'neutral',
        'confidence': min(0.9, max_tone[1] * 0.3),
        'scores': tone_scores
    }
Enter fullscreen mode Exit fullscreen mode

性能优化

VoiceAccess实现了全面的性能监控和优化:

class PerformanceMonitor:
    def __init__(self):
        self.thresholds = {
            'max_latency_ms': 300,
            'max_cpu_percent': 80.0,
            'max_memory_percent': 85.0,
            'min_accuracy': 0.85
        }

    def _check_performance_alerts(self, metrics: PerformanceMetrics):
        """Real-time performance monitoring with alerts"""
        if metrics.latency_ms > self.thresholds['max_latency_ms']:
            self._add_alert(
                'high_latency',
                f"High latency detected: {metrics.latency_ms:.0f}ms",
                'warning'
            )

        if metrics.cpu_percent > self.thresholds['max_cpu_percent']:
            self._add_alert(
                'high_cpu',
                f"High CPU usage: {metrics.cpu_percent:.1f}%",
                'warning'
            )

    def _calculate_performance_score(self, metrics: List[PerformanceMetrics]) -> float:
        """Comprehensive performance scoring algorithm"""
        scores = []

        # Latency score (lower is better)
        latencies = [m.latency_ms for m in metrics if m.latency_ms > 0]
        if latencies:
            avg_latency = sum(latencies) / len(latencies)
            latency_score = max(0, 100 - (avg_latency / self.thresholds['max_latency_ms']) * 100)
            scores.append(latency_score)

        return sum(scores) / len(scores) if scores else 0.0
Enter fullscreen mode Exit fullscreen mode

无障碍优先设计

符合 WCAG 2.1 AA 标准

VoiceAccess从一开始就将无障碍功能作为首要考虑因素,而不是事后才考虑的:

class AccessibilityFeatures:
    def __init__(self):
        # WCAG 2.1 AA compliant color schemes
        self.high_contrast_colors = {
            'background': '#000000',
            'text': '#ffffff',
            'primary': '#ffffff',
            'success': '#00ff00',
            'warning': '#ffff00',
            'error': '#ff0000'
        }

    def validate_color_contrast(self, foreground: str, background: str) -> Dict[str, Any]:
        """WCAG 2.1 color contrast validation"""
        contrast_ratio = self._calculate_contrast_ratio(foreground, background)

        return {
            'contrast_ratio': contrast_ratio,
            'aa_normal': contrast_ratio >= 4.5,
            'aa_large': contrast_ratio >= 3.0,
            'aaa_normal': contrast_ratio >= 7.0,
            'wcag_level': 'AAA' if contrast_ratio >= 7.0 else 'AA' if contrast_ratio >= 4.5 else 'Fail'
        }
Enter fullscreen mode Exit fullscreen mode

视觉辅助功能

该应用程序提供全面的视觉辅助功能选项:

  • 高对比度模式:切换到黑底白字的配色方案,提高对比度。
  • 可缩放字体:字体大小从 12px 到 28px,并具有最佳行间距
  • 视觉警报系统:重要事件的通知将以闪光灯通知代替音频提示。
  • 色盲友好型调色板:针对各种色觉缺陷的替代配色方案
  • 焦点管理:清晰的键盘导航视觉焦点指示器

键盘导航

完整的键盘操作功能确保即使无法使用鼠标的用户也能使用该应用程序:

def create_focus_management(self):
    """Comprehensive keyboard navigation implementation"""
    focus_script = """
    document.addEventListener('keydown', function(e) {
        if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') {
            switch(e.key.toLowerCase()) {
                case ' ':
                    // Space for start/stop recording
                    const recordButton = document.querySelector('[data-testid="baseButton-secondary"]');
                    if (recordButton) {
                        recordButton.click();
                        e.preventDefault();
                    }
                    break;
                case 's':
                    // S for settings panel
                    const settingsSection = document.querySelector('.stSidebar');
                    if (settingsSection) {
                        settingsSection.scrollIntoView();
                        e.preventDefault();
                    }
                    break;
            }
        }
    });
    """
Enter fullscreen mode Exit fullscreen mode

绩效指标

延迟成就

VoiceAccess 通过多种优化策略,始终能够实现低于 300 毫秒的转录延迟:

  • 优化的音频管道:最小缓冲和高效的预处理
  • 简化的 API 集成:直接通过 WebSocket 连接到 AssemblyAI Universal-Streaming
  • 高效的 UI 更新:异步更新可防止阻塞操作
  • 智能缓存:对非关键数据进行智能缓存,以减少处理开销。

性能基准测试结果显示:

  • 平均延迟:正常情况下为 180-250 毫秒
  • 峰值性能:在最佳网络条件下可实现低于 150 毫秒的延迟
  • 一致性:95% 的请求在 300 毫秒目标时间内完成
  • 可扩展性:在长时间使用过程中保持性能

系统资源优化

该应用程序设计轻巧高效:

def get_optimization_recommendations(self) -> List[str]:
    """Dynamic performance optimization suggestions"""
    recommendations = []

    if avg_latency > self.thresholds['max_latency_ms']:
        recommendations.append("Reduce audio chunk size to improve latency")
        recommendations.append("Check network connection quality")

    if avg_cpu > self.thresholds['max_cpu_percent']:
        recommendations.append("Close unnecessary applications to reduce CPU load")
        recommendations.append("Consider reducing audio quality settings")

    return recommendations
Enter fullscreen mode Exit fullscreen mode

实时监控

全面的性能监控能够深入了解系统行为:

  • 实时延迟跟踪:实时显示转录延迟
  • 资源利用率:CPU 和内存使用情况监控
  • 连接质量:网络稳定性和 API 响应时间跟踪
  • 准确性指标:转录置信度和错误率监控
  • 用户体验指标:界面响应速度和交互跟踪

创新亮点

多模态反馈系统

VoiceAccess率先采用了一种综合性的多模态反馈方法:

def render_transcript_display(self, transcripts: List[Dict], accessibility_settings: Dict):
    """Multi-modal transcript display with rich visual feedback"""
    for transcript in transcripts:
        confidence_color = "#28a745" if confidence > 0.8 else "#ffc107" if confidence > 0.6 else "#dc3545"

        transcript_html = f"""
        <div style="
            background-color: {'#333333' if high_contrast else '#f8f9fa'};
            border-left: 4px solid {confidence_color};
            padding: 15px;
            margin: 10px 0;
        ">
            <div class="speaker-info">
                <strong>{speaker}</strong> • {timestamp} • 
                <span style="color: {confidence_color}">
                    {confidence:.1%} confidence
                </span>
            </div>
            <div class="transcript-text">{text}</div>
        </div>
        """
Enter fullscreen mode Exit fullscreen mode

自适应用户界面

界面会根据用户需求和偏好动态调整:

  • 上下文感知调整:界面元素根据内容重要性调整大小
  • 预测性辅助功能:基于用户交互模式的自动调整
  • 渐进增强:功能根据系统性能优雅地降级
  • 响应式设计:在不同屏幕尺寸和设备上提供最佳体验

智能错误恢复

完善的错误处理机制确保持续运行:

def _reconnect(self):
    """Intelligent reconnection with exponential backoff"""
    max_retries = 3
    retry_delay = 2

    for attempt in range(max_retries):
        logger.info(f"Reconnection attempt {attempt + 1}/{max_retries}")

        self.disconnect()
        time.sleep(retry_delay)

        if self.connect():
            logger.info("Reconnection successful")
            return

        retry_delay *= 2  # Exponential backoff

    logger.error("Failed to reconnect after maximum retries")
Enter fullscreen mode Exit fullscreen mode

安装和设置

快速入门指南

VoiceAccess 提供多种安装途径,以适应不同的系统配置:

  1. 自动安装(推荐):
   python install_dependencies.py
Enter fullscreen mode Exit fullscreen mode
  1. 最小安装(适用于存在依赖问题的系统):
   pip install -r requirements-minimal.txt
Enter fullscreen mode Exit fullscreen mode
  1. 手动安装(分步控制):
   pip install streamlit assemblyai sounddevice numpy python-dotenv pandas plotly psutil requests
Enter fullscreen mode Exit fullscreen mode

Windows友好型安装

考虑到在 Windows 系统上安装 Python 包的挑战,VoiceAccess 包含以下内容:

  • 具有优雅回退机制的自动依赖关系解析
  • 针对问题依赖项的预编译软件包替代方案
  • 提供全面的错误处理方案和清晰的解决方案指南
  • 针对不同 Windows 配置的替代安装方法

备用模拟模式

对于无法安装音频库的系统,VoiceAccess 提供完整的模拟模式:

class FallbackAudioProcessor:
    """Simulation mode for testing without audio hardware"""

    def _generate_mock_audio(self) -> bytes:
        """Generate realistic mock audio data"""
        samples = np.random.randint(-1000, 1000, self.config.chunk_size, dtype=np.int16)
        t = np.linspace(0, 1, self.config.chunk_size)
        sine_wave = (np.sin(2 * np.pi * 440 * t) * 500).astype(np.int16)
        mixed = (samples * 0.3 + sine_wave * 0.7).astype(np.int16)
        return mixed.tobytes()
Enter fullscreen mode Exit fullscreen mode

这样即使没有可用的音频输入,也能演示和测试所有应用程序功能。

影响与未来愿景

实际应用

VoiceAccess 满足了现实世界中无障碍访问的关键需求:

  • 教育场景:为聋生提供实时讲座转录
  • 职场沟通:会议无障碍性和包容性协作
  • 医疗保健:患者与医护人员沟通协助
  • 公共服务:便捷的客户服务和信息获取
  • 社交互动:更积极地参与小组对话

社区影响

该应用程序的开源特性和全面的文档使其具备以下优势:

  • 开发者教育:面向无障碍开发的学习资源
  • 社区贡献:附加辅助功能框架
  • 研究应用:用于研究实时通信可访问性的平台
  • 商业应用:企业无障碍解决方案的基础

未来改进

计划改进措施包括:

  • 多语言支持:扩展至英语转录以外的语言
  • 高级人工智能集成:基于 GPT 的对话摘要
  • 移动应用:原生 iOS 和 Android 实现
  • 硬件集成:支持专用辅助设备
  • 云部署:可扩展的多用户实现
  • API开发:用于第三方集成的RESTful API

VoiceAccess 项目代表着在使每个人都能进行实时通信方面迈出了重要一步,它展示了如何利用尖端人工智能技术创造有意义的社会影响,同时在性能和可访问性方面实现卓越的技术水平。

文章来源:https://dev.to/mohamednizzad/voice-of-voiceless-enabling-the-voiceless-to-communicate-1ejp