o
    Ö­j©  ã                   @  sV   d dl mZ d dlZd dlmZ d dlmZ d dlmZ e 	e
¡Zddœddd„ZdS )é    )ÚannotationsN)ÚBytesIO)Ú	AudioData)Ú
SetupErrorzcohere-transcribe-03-2026)ÚmodelÚ
audio_datar   ÚlanguageÚstrr   Úreturnc                C  sx   zddl }W n ty   tdƒ‚w t|tƒstdƒ‚t| ¡ ƒ}d|_| 	¡ }t
 d||¡ |jjj|||d�}|jS )a8  Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the `Cohere Transcribe <https://docs.cohere.com/docs/transcribe>`__ API via the official Python SDK.

    Requires the ``cohere`` package (install with ``pip install SpeechRecognition[cohere-api]``).
    Set environment variable ``CO_API_KEY`` as documented by Cohere; this library does not read or override it in code.

    ``language`` is required by the Cohere transcription API (e.g. ``"en"``, ``"ja"``).

    Detail: https://docs.cohere.com/reference/create-audio-transcription
    r   Nzomissing cohere module: ensure that cohere is set up correctly (e.g. pip install SpeechRecognition[cohere-api]).z0``audio_data`` must be an ``AudioData`` instancezSpeechRecognition_audio.wavz8cohere audio.transcriptions.create: model=%r language=%r)r   Úfiler   )ÚcohereÚImportErrorr   Ú
isinstancer   Ú
ValueErrorr   Úget_wav_dataÚnameÚClientV2ÚloggerÚdebugÚaudioÚtranscriptionsÚcreateÚtext)Ú
recognizerr   r   r   r   Úwav_dataÚclientÚresponse© r   úf/var/www/html/CropPilot/venv/lib/python3.10/site-packages/speech_recognition/recognizers/cohere_api.pyÚ	recognize   s.   ÿÿ
ýýr   )r   r   r   r	   r   r	   r
   r	   )Ú
__future__r   ÚloggingÚior   Úspeech_recognition.audior   Úspeech_recognition.exceptionsr   Ú	getLoggerÚ__name__r   r   r   r   r   r   Ú<module>   s    
û