Skip to main content
Glama
balloonf

Windows TTS MCP Server

by balloonf

speak_short

Convert short text (up to 100 characters) into speech instantly using Windows' built-in Speech API for quick and efficient auditory communication.

Instructions

짧은 텍스트를 즉시 읽어줍니다 (100자 이하)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Implementation Reference

  • Main handler for 'speak_short' tool. Validates text length (<=100 chars), spawns daemon thread to execute TTS via powershell_tts.
    @mcp.tool()
    def speak_short(text: str) -> str:
        """짧은 텍스트를 즉시 읽어줍니다 (100자 이하)"""
        try:
            if len(text) > 100:
                return "[ERROR] 텍스트가 너무 깁니다. speak를 사용하세요."
            
            def _speak_short():
                powershell_tts(text)
            
            thread = threading.Thread(target=_speak_short, daemon=True)
            thread.start()
            
            return f"[SHORT] 짧은 텍스트 재생: '{text}'"
            
        except Exception as e:
            return f"[ERROR] 짧은 텍스트 재생 오류: {str(e)}"
  • Core helper function that performs the actual TTS synthesis using PowerShell's System.Speech.Synthesis. Manages subprocess execution, threading locks for process tracking, timeouts, and error recovery. Called by speak_short.
    def powershell_tts(text: str, rate: int = 0, volume: int = 100) -> bool:
        """PowerShell을 사용한 TTS 실행"""
        process = None
        try:
            if platform.system() != "Windows":
                safe_print("[ERROR] Windows가 아닙니다")
                return False
            
            # 텍스트에서 작은따옴표 이스케이프 처리
            escaped_text = text.replace("'", "''")
            
            # PowerShell TTS 명령어
            cmd = [
                "powershell", "-Command",
                f"Add-Type -AssemblyName System.Speech; "
                f"$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
                f"$synth.Rate = {rate}; "
                f"$synth.Volume = {volume}; "
                f"$synth.Speak('{escaped_text}'); "
                f"$synth.Dispose()"
            ]
            
            # 프로세스 시작
            process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
            
            # 실행 중인 프로세스 목록에 추가
            with process_lock:
                running_processes.append(process)
            
            # 프로세스 완료 대기
            stdout, stderr = process.communicate(timeout=180)
            
            # 완료된 프로세스 목록에서 제거
            with process_lock:
                if process in running_processes:
                    running_processes.remove(process)
            
            if process.returncode == 0:
                safe_print(f"[SUCCESS] TTS 완료: {text[:30]}...")
                return True
            else:
                safe_print(f"[ERROR] TTS 오류: {stderr}")
                return False
                
        except subprocess.TimeoutExpired:
            safe_print("[WARNING] TTS 시간 초과")
            if process:
                process.kill()
                with process_lock:
                    if process in running_processes:
                        running_processes.remove(process)
            return False
        except Exception as e:
            safe_print(f"[ERROR] TTS 예외: {e}")
            if process:
                try:
                    process.kill()
                    with process_lock:
                        if process in running_processes:
                            running_processes.remove(process)
                except:
                    pass
            return False
  • Global variables for managing running TTS processes and thread-safe locking, used by powershell_tts and other TTS functions including speak_short.
    # 실행 중인 TTS 프로세스 관리
    running_processes = []
    process_lock = threading.Lock()
  • FastMCP decorator that registers the speak_short function as a tool.
    @mcp.tool()
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/balloonf/widows_tts_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server