You've already forked Irene-Voice-Assistant
mirror of
https://github.com/janvarev/Irene-Voice-Assistant.git
synced 2025-11-26 22:50:58 +02:00
rename main classes to VACore. Use VA prefix everywhere
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# Core plugin
|
||||
# author: Vladislav Janvarev
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Core plugin",
|
||||
"version": "1.7",
|
||||
@@ -24,7 +24,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
#print(manifest["options"])
|
||||
options = manifest["options"]
|
||||
#core.setup_assistant_voice(options["ttsIndex"])
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# author: Vladislav Janvarev (inspired by EnjiRouz)
|
||||
|
||||
import random
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Привет",
|
||||
"version": "1.0",
|
||||
@@ -17,7 +17,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def play_greetings(core:VoiceAssCore, phrase: str):
|
||||
def play_greetings(core:VACore, phrase: str):
|
||||
"""
|
||||
Проигрывание случайной приветственной речи
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ import time
|
||||
import os
|
||||
|
||||
#from voiceassmain import play_voice_assistant_speech
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
# опции
|
||||
useYandexMusicShortcuts = False
|
||||
@@ -14,7 +14,7 @@ useMPCHCRemote = False
|
||||
mpchc = None
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Команды управления мультимедия",
|
||||
"version": "1.1",
|
||||
@@ -46,14 +46,14 @@ def start(core:VoiceAssCore):
|
||||
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
#print(manifest["options"])
|
||||
global useYandexMusicShortcuts
|
||||
options = manifest["options"]
|
||||
|
||||
useYandexMusicShortcuts = options["useYandexMusicShortcuts"]
|
||||
|
||||
def play_pause(core:VoiceAssCore, phrase: str):
|
||||
def play_pause(core:VACore, phrase: str):
|
||||
print("Команда пауза")
|
||||
#pyautogui.keyDown("space")
|
||||
if useMPCHCRemote:
|
||||
@@ -66,7 +66,7 @@ def play_pause(core:VoiceAssCore, phrase: str):
|
||||
pyautogui.press("space") # универсально для всех
|
||||
|
||||
|
||||
def play_next(core:VoiceAssCore, phrase: str):
|
||||
def play_next(core:VACore, phrase: str):
|
||||
print("Команда дальше")
|
||||
|
||||
if useMPCHCRemote:
|
||||
@@ -81,7 +81,7 @@ def play_next(core:VoiceAssCore, phrase: str):
|
||||
if useYandexMusicShortcuts:
|
||||
pyautogui.press("l")
|
||||
|
||||
def play_prev(core:VoiceAssCore, phrase: str):
|
||||
def play_prev(core:VACore, phrase: str):
|
||||
print("Команда назад")
|
||||
|
||||
if useMPCHCRemote:
|
||||
@@ -95,7 +95,7 @@ def play_prev(core:VoiceAssCore, phrase: str):
|
||||
if useYandexMusicShortcuts:
|
||||
pyautogui.press("k")
|
||||
|
||||
def toggle_mute(core:VoiceAssCore, phrase: str):
|
||||
def toggle_mute(core:VACore, phrase: str):
|
||||
if useMPCHCRemote:
|
||||
try:
|
||||
mpchc.volume_mute()
|
||||
@@ -105,17 +105,17 @@ def toggle_mute(core:VoiceAssCore, phrase: str):
|
||||
|
||||
pyautogui.press("volumemute")
|
||||
|
||||
def volume_upX(core:VoiceAssCore, phrase: str, param:int):
|
||||
def volume_upX(core:VACore, phrase: str, param:int):
|
||||
for i in range(param):
|
||||
volume_up1(core,phrase)
|
||||
|
||||
def volume_downX(core:VoiceAssCore, phrase: str, param:int):
|
||||
def volume_downX(core:VACore, phrase: str, param:int):
|
||||
for i in range(param):
|
||||
volume_down1(core,phrase)
|
||||
|
||||
|
||||
|
||||
def volume_up1(core:VoiceAssCore, phrase: str):
|
||||
def volume_up1(core:VACore, phrase: str):
|
||||
if useMPCHCRemote:
|
||||
try:
|
||||
mpchc.volume_up()
|
||||
@@ -125,7 +125,7 @@ def volume_up1(core:VoiceAssCore, phrase: str):
|
||||
|
||||
pyautogui.press("volumeup")
|
||||
|
||||
def volume_down1(core:VoiceAssCore, phrase: str):
|
||||
def volume_down1(core:VACore, phrase: str):
|
||||
if useMPCHCRemote:
|
||||
try:
|
||||
mpchc.volume_down()
|
||||
@@ -135,7 +135,7 @@ def volume_down1(core:VoiceAssCore, phrase: str):
|
||||
|
||||
pyautogui.press("volumedown")
|
||||
|
||||
def close(core:VoiceAssCore, phrase: str):
|
||||
def close(core:VACore, phrase: str):
|
||||
if useMPCHCRemote:
|
||||
try:
|
||||
mpchc.exit()
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
import subprocess
|
||||
|
||||
#from voiceassmain import play_voice_assistant_speech
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
|
||||
multPath = ""
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "MPC-HC проигрывание мультиков",
|
||||
"version": "1.2",
|
||||
@@ -27,7 +27,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
#print(manifest["options"])
|
||||
global multPath
|
||||
options = manifest["options"]
|
||||
@@ -36,10 +36,10 @@ def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
|
||||
return manifest
|
||||
|
||||
def run_player(core:VoiceAssCore, phrase: str):
|
||||
def run_player(core:VACore, phrase: str):
|
||||
subprocess.Popen([core.mpcHcPath])
|
||||
|
||||
def play_mult(core:VoiceAssCore, phrase: str):
|
||||
def play_mult(core:VACore, phrase: str):
|
||||
if phrase == "":
|
||||
core.play_voice_assistant_speech("Пожалуйста, уточни какой именно мультик")
|
||||
# здесь надо вернуть контекст, чтобы не добавлять Ирина. но это позже
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import time
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
import utils.num_to_text_ru as num_to_text
|
||||
|
||||
female_units_min2 = ((u'минуту', u'минуты', u'минут'), 'f')
|
||||
@@ -16,7 +16,7 @@ female_units_sec = ((u'секунда', u'секунды', u'секунд'), 'f'
|
||||
modname = os.path.basename(__file__)[:-3] # calculating modname
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Таймер",
|
||||
"version": "1.2",
|
||||
@@ -33,10 +33,10 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
pass
|
||||
|
||||
def set_timer(core:VoiceAssCore,phrase:str):
|
||||
def set_timer(core:VACore, phrase:str):
|
||||
if phrase == "":
|
||||
# таймер по умолчанию - на 5 минут
|
||||
txt = num_to_text.num2text(5, female_units_min)
|
||||
@@ -89,11 +89,11 @@ def set_timer(core:VoiceAssCore,phrase:str):
|
||||
set_timer_real(core,1*60,txt)
|
||||
return
|
||||
|
||||
def set_timer_real(core:VoiceAssCore,num:int,txt:str):
|
||||
def set_timer_real(core:VACore, num:int, txt:str):
|
||||
core.set_timer(num,(after_timer, txt))
|
||||
core.play_voice_assistant_speech("Ставлю таймер на "+txt)
|
||||
|
||||
def after_timer(core:VoiceAssCore,txt:str):
|
||||
def after_timer(core:VACore, txt:str):
|
||||
options = core.plugin_options(modname)
|
||||
|
||||
for i in range(options["wavRepeatTimes"]):
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
import pyttsx3
|
||||
|
||||
modname = os.path.basename(__file__)[:-3] # calculating modname
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "TTS console (for debug)",
|
||||
"version": "1.0",
|
||||
@@ -21,9 +21,9 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def init(core:VoiceAssCore):
|
||||
def init(core:VACore):
|
||||
pass
|
||||
|
||||
def say(core:VoiceAssCore,text_to_speech:str):
|
||||
def say(core:VACore, text_to_speech:str):
|
||||
# просто выводим текст в консоль
|
||||
print("TTS: {}".format(text_to_speech))
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
import pyttsx3
|
||||
|
||||
modname = os.path.basename(__file__)[:-3] # calculating modname
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "TTS pyttsx",
|
||||
"version": "1.0",
|
||||
@@ -25,10 +25,10 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
pass
|
||||
|
||||
def init(core:VoiceAssCore):
|
||||
def init(core:VACore):
|
||||
options = core.plugin_options(modname)
|
||||
|
||||
core.ttsEngine = pyttsx3.init()
|
||||
@@ -56,7 +56,7 @@ def init(core:VoiceAssCore):
|
||||
core.ttsEngine.setProperty("voice", voices[options["sysId"]].id)
|
||||
core.ttsEngine.setProperty("volume", 1.0)
|
||||
|
||||
def say(core:VoiceAssCore,text_to_speech:str):
|
||||
def say(core:VACore, text_to_speech:str):
|
||||
"""
|
||||
Проигрывание речи ответов голосового ассистента (без сохранения аудио)
|
||||
:param text_to_speech: текст, который нужно преобразовать в речь
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
modname = os.path.basename(__file__)[:-3] # calculating modname
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Погода (open weather map)",
|
||||
"version": "1.0",
|
||||
@@ -32,7 +32,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
|
||||
options = manifest["options"]
|
||||
|
||||
@@ -67,7 +67,7 @@ def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
|
||||
return
|
||||
|
||||
def run_weather(core:VoiceAssCore,phrase:str,addparam:str):
|
||||
def run_weather(core:VACore, phrase:str, addparam:str):
|
||||
|
||||
options = core.plugin_options(modname)
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
modname = os.path.basename(__file__)[:-3] # calculating modname
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Яндекс Расписания",
|
||||
"version": "1.0",
|
||||
@@ -28,10 +28,10 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
pass
|
||||
|
||||
def run_poezd(core:VoiceAssCore,phrase:str):
|
||||
def run_poezd(core:VACore, phrase:str):
|
||||
|
||||
options = core.plugin_options(modname)
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ import pyautogui
|
||||
import time
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Яндекс Музыка",
|
||||
"version": "1.0",
|
||||
@@ -19,7 +19,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def run_yamus(core:VoiceAssCore,phrase:str):
|
||||
def run_yamus(core:VACore, phrase:str):
|
||||
if core != None:
|
||||
core.play_voice_assistant_speech("Запускаю музыку")
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
import os
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
modname = os.path.basename(__file__)[:-3] # calculating modname
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "TTS silero",
|
||||
"version": "1.0",
|
||||
@@ -26,10 +26,10 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def start_with_options(core:VoiceAssCore,manifest:dict):
|
||||
def start_with_options(core:VACore, manifest:dict):
|
||||
pass
|
||||
|
||||
def init(core:VoiceAssCore):
|
||||
def init(core:VACore):
|
||||
options = core.plugin_options(modname)
|
||||
|
||||
import os
|
||||
@@ -51,7 +51,7 @@ def init(core:VoiceAssCore):
|
||||
#core.model.
|
||||
|
||||
|
||||
def say(core:VoiceAssCore,text_to_speech:str):
|
||||
def say(core:VACore, text_to_speech:str):
|
||||
# simple way
|
||||
paths = core.model.save_wav(texts=[text_to_speech],
|
||||
sample_rate=16000)
|
||||
|
||||
@@ -3,11 +3,11 @@ import time
|
||||
import os
|
||||
|
||||
#from voiceassmain import play_voice_assistant_speech
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
# based on EnjiRouz realization https://github.com/EnjiRouz/Voice-Assistant-App/blob/master/app.py
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Википедия (поиск)",
|
||||
"version": "1.0",
|
||||
@@ -19,7 +19,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def run_wiki(core:VoiceAssCore,phrase:str):
|
||||
def run_wiki(core:VACore, phrase:str):
|
||||
# if core != None:
|
||||
# core.play_voice_assistant_speech("Ищу на вики {}".format(phrase))
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ import time
|
||||
import os
|
||||
|
||||
#from voiceassmain import play_voice_assistant_speech
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
# based on EnjiRouz realization https://github.com/EnjiRouz/Voice-Assistant-App/blob/master/app.py
|
||||
|
||||
# функция на старте
|
||||
def start(core:VoiceAssCore):
|
||||
def start(core:VACore):
|
||||
manifest = {
|
||||
"name": "Ютуб (поиск)",
|
||||
"version": "1.0",
|
||||
@@ -19,7 +19,7 @@ def start(core:VoiceAssCore):
|
||||
}
|
||||
return manifest
|
||||
|
||||
def run_youtube(core:VoiceAssCore,phrase:str):
|
||||
def run_youtube(core:VACore, phrase:str):
|
||||
if core != None:
|
||||
core.play_voice_assistant_speech("Ищу на ютуб {}".format(phrase))
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import traceback
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
import time
|
||||
|
||||
# ------------------- main loop ------------------
|
||||
if __name__ == "__main__":
|
||||
cmd_core = VoiceAssCore()
|
||||
cmd_core = VACore()
|
||||
cmd_core.init_with_plugins()
|
||||
print("Command-line for VoiceAssCore.")
|
||||
print("Command-line for VoiceAssistantCore.")
|
||||
print("Enter command (user text like 'привет') or 'exit'")
|
||||
|
||||
# почему бы сразу не отладить какую-то команду?
|
||||
@@ -7,7 +7,7 @@ import sys
|
||||
import traceback
|
||||
import json
|
||||
|
||||
from voiceasscore import VoiceAssCore
|
||||
from vacore import VACore
|
||||
|
||||
mic_blocked = False
|
||||
|
||||
@@ -87,7 +87,7 @@ if __name__ == "__main__":
|
||||
rec = vosk.KaldiRecognizer(model, args.samplerate)
|
||||
|
||||
# initing core
|
||||
core = VoiceAssCore()
|
||||
core = VACore()
|
||||
#core.init_plugin("core")
|
||||
#core.init_plugins(["core"])
|
||||
core.init_with_plugins()
|
||||
@@ -10,7 +10,7 @@ from jaa import JaaCore
|
||||
|
||||
version = "2.0"
|
||||
|
||||
class VoiceAssCore(JaaCore):
|
||||
class VACore(JaaCore):
|
||||
def __init__(self):
|
||||
JaaCore.__init__(self)
|
||||
|
||||
@@ -20,29 +20,9 @@ class VoiceAssCore(JaaCore):
|
||||
self.timersDuration = [0,0,0,0,0,0,0,0]
|
||||
|
||||
self.commands = {
|
||||
#"привет|доброе утро": play_greetings,
|
||||
#"мультик": play_mult,
|
||||
|
||||
|
||||
# ("привет"): play_greetings,
|
||||
# ("мультик"): play_mult,
|
||||
# ("пауза"): play_pause,
|
||||
# ("дальше", "вперед"): play_next,
|
||||
# ("назад"): play_prev,
|
||||
|
||||
# ("bye", "goodbye", "quit", "exit", "stop", "пока"): play_farewell_and_quit,
|
||||
# ("search", "google", "find", "найди"): search_for_term_on_google,
|
||||
# ("video", "youtube", "watch", "видео"): search_for_video_on_youtube,
|
||||
# ("wikipedia", "definition", "about", "определение", "википедия"): search_for_definition_on_wikipedia,
|
||||
# ("translate", "interpretation", "translation", "перевод", "перевести", "переведи"): get_translation,
|
||||
# ("language", "язык"): change_language,
|
||||
# ("weather", "forecast", "погода", "прогноз"): get_weather_forecast,
|
||||
# ("facebook", "person", "run", "пробей", "контакт"): run_person_through_social_nets_databases,
|
||||
# ("toss", "coin", "монета", "подбрось"): toss_coin,
|
||||
}
|
||||
|
||||
self.ttss = {
|
||||
|
||||
}
|
||||
|
||||
# more options
|
||||
@@ -65,9 +45,9 @@ class VoiceAssCore(JaaCore):
|
||||
def init_with_plugins(self):
|
||||
self.init_plugins(["core"])
|
||||
if self.isOnline:
|
||||
print("VoiceAssCore v{0}: run online".format(version))
|
||||
print("VoiceAssistantCore v{0}: run online".format(version))
|
||||
else:
|
||||
print("VoiceAssCore v{0}: run OFFLINE".format(version))
|
||||
print("VoiceAssistantCore v{0}: run OFFLINE".format(version))
|
||||
print("TTS engines: ",self.ttss.keys())
|
||||
print("Commands list: ",self.commands.keys())
|
||||
print("Assistant names: ",self.voiceAssNames)
|
||||
Reference in New Issue
Block a user