Skip to main content
Glama

MCP Agent Platform

ear_agent.cpython-310.pyc2.41 kB
o ��g� �@sTdZddlZddlmZmZddlZddlmZddl m Z m Z Gdd�de�Z dS)u 听觉智能体 �N)�Dict�Any)� BaseAgent)� AudioMessage� TextMessagecsJeZdZdededef�fdd� Z�fdd�Z�fdd �Zd d �Z�Z S) �EarAgent�agent_id�host�portcs&t��|d||�t��|_d|_dS)N� audio_inputF)�super�__init__�srZ Recognizer� recognizer� is_listening)�selfrr r �� __class__��4D:\DeepSeek\MCPAgent\mcpTest\src\agents\ear_agent.pyr s  zEarAgent.__init__c�s*�t���IdHd|_t�|���dS)u启动听觉智能体NT)r �startr�asyncio� create_task� _listen_loop�rrrrrs�zEarAgent.startc�s�d|_t���IdHdS)u停止听觉智能体FN)rr �stoprrrrrs�z EarAgent.stopc �s��|jr�zot���a}|j�d�tj|jj|ddd�IdH}d}t |�D]+}ztj|jj |dd�IdH}Wntj yO||d krE�t� d �IdHYq$wt |jd |d �}|�d |���IdHWd�n1smwYWnUtjy�|j�d �YnFtj y�}z|j�d |���t� d�IdHWYd}~n'd}~wty�}z|j�d|���t� d �IdHWYd}~nd}~ww|jsdSdS)u持续监听音频的循环z Listening...�� )�timeoutZphrase_time_limitN�zzh-CN)�language��brain)� sender_id� receiver_id�textzCould not understand audioz'Error with speech recognition service: �zError in listen loop: )rrZ Microphone�logger�infor� to_threadr�listen�rangeZrecognize_google� RequestError�sleeprr� send_message�to_dictZUnknownValueError�error� Exception)r�source�audio� max_retries�attemptr%�message�errrrsZ�   �  � ���� ����zEarAgent._listen_loop) �__name__� __module__� __qualname__�str�intr rrr� __classcell__rrrrr s   r) �__doc__Zspeech_recognitionr�typingrrr�src.agents.base_agentr�src.utils.mcp_protocolrrrrrrr�<module>s 

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/rolenet/McpAgentRobot'

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