mirror of
https://github.com/DinoMalin/paranoia-1.0.git
synced 2025-10-29 19:05:59 +00:00
23 lines
839 B
Python
23 lines
839 B
Python
import azure.cognitiveservices.speech as speechsdk
|
|
from dotenv import load_dotenv
|
|
import os
|
|
|
|
load_dotenv()
|
|
|
|
speech_config = speechsdk.SpeechConfig(
|
|
subscription=os.getenv("SPEECH_KEY"), region=os.getenv("REGION"))
|
|
speech_config.speech_recognition_language = "fr-FR"
|
|
|
|
audio_out = speechsdk.audio.AudioOutputConfig(use_default_speaker=True)
|
|
|
|
# A filthy shortcut because i have incomprehensible bugs with my libs.
|
|
# If your pc is normal unlike mine, consider replacing this argument with:
|
|
# use_default_microphone=True
|
|
audio_config = speechsdk.audio.AudioConfig(device_name="plughw:2,0") # fuck this man
|
|
|
|
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
|
|
|
|
print("listen")
|
|
speech_recognition_result = speech_recognizer.recognize_once_async().get()
|
|
print(speech_recognition_result.text)
|