@Oneqaz

Почему при активации программы голосового калькулятора перестаёт идти звук от Дискорда и Скайпа?

import speech_recognition as sp
import pyttsx3
import random

r = sp.Recognizer()
r.pause_threshold = 0.3
mic = sp.Microphone()

Ran = random.randint(100, 120)

tts = pyttsx3.init()
tts.setProperty('rate', Ran)

def speak(what):
    print( what )
    tts.say( what )
    tts.runAndWait()
    tts.stop()

speak("hello this is calculation mastubration")

with mic as source:
    r.adjust_for_ambient_noise(source, duration=0.5)
    speak("Please say the first number")
    audio = r.listen(source)

a1 = r.recognize_google(audio, language="ru_RU")

print(a1)

with mic as source:
    speak("Okay, and the second number")
    audio = r.listen(source)

a2 = r.recognize_google(audio, language="ru_RU")

print(a2)

try:
    result = int(a1) + int(a2)
    speak("Nice, and if I add these numbers, result is " + str(result) )
except ValueError:
    speak("Please says the numbers")
    print("\n Цифри говори даун")
  • Вопрос задан
  • 71 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы