瀏覽代碼

Init Commit

Patrick Baumgartner 3 年之前
父節點
當前提交
ddabc2d207
共有 11 個文件被更改,包括 27 次插入25 次删除
  1. 8 8
      DynLoader/modInfo.py
  2. 1 1
      Jessi/ContentFile.py
  3. 1 1
      Jessi/main.py
  4. 2 1
      README.md
  5. 0 1
      Stats/main.py
  6. 2 0
      Trixy.pyproj
  7. 1 1
      main.py
  8. 1 1
      mods/BaseMod.py
  9. 0 4
      mods/ModPlaySound/__init__.py
  10. 9 5
      mods/WindowsSay/__init__.py
  11. 2 2
      ressources/texts/test.json

+ 8 - 8
DynLoader/modInfo.py

@@ -59,13 +59,13 @@ class modInfo(object):
     def _loadModule(self, moduleName:str):
         module = None
         moduleName = self._classPath + "." + self._className
-        print("- moduleName: " + moduleName)
+        #print("- moduleName: " + moduleName)
         try:
             del sys.modules[moduleName]
         except BaseException as err:
             pass
         try:
-            print("try to import module "+moduleName)
+            #print("try to import module "+moduleName)
             module = importlib.import_module(moduleName)
         except BaseException as err:
             serr = str(err)
@@ -115,21 +115,21 @@ class modInfo(object):
             return
         self._path = value
         if os.path.isfile(value):
-            print("- file exists")
+            #print("- file exists")
             self._size = os.path.getsize(self._path)
-            print("- size: " + str(self._size))
+            #print("- size: " + str(self._size))
             try:
                 #self._mod = __import__(self._path)
                 self._mod = self._loadModule(self._path)
-                print("- _loadModule("+self._path+") done")
+                #print("- _loadModule("+self._path+") done")
                 self._instance = getattr(self._mod, self._className)()
                 if self._instance==None:
-                    print("- failed to create instance")
+                    #print("- failed to create instance")
                     self._loaded = False
                 else:
-                    print("instance created")
+                    #print("instance created")
                     self._loaded = True
-                print("- loaded done")
+                #print("- loaded done")
             except ImportError:
                 print("- ImportError")
                 self._mod = None

+ 1 - 1
Jessi/ContentFile.py

@@ -23,7 +23,7 @@ class ContentFile(object):
         self.entries.clear()
         self.entries = list()
         stats = Stats.Stats.getInstance()
-        with open('ressources/texts/'+self._file) as f:
+        with open('ressources/texts/'+self._file, encoding="utf-8") as f:
             data = json.load(f)
 
         for i in data:

+ 1 - 1
Jessi/main.py

@@ -142,7 +142,7 @@ class Text:
 
     def readReplacer(self):
         tmp = {}
-        with open("ressources/texts/Replacer.json") as json_file:
+        with open("ressources/texts/Replacer.json", encoding="utf-8") as json_file:
             data = json.load(json_file)
         for k in data:
             tmp[k] = list()

+ 2 - 1
README.md

@@ -14,4 +14,5 @@ pydub
 librosa  
 configparser  
 deepspeech  
-pyyaml  
+pyyaml  
+nanotts  

+ 0 - 1
Stats/main.py

@@ -388,7 +388,6 @@ class Stats:
         else:
             self._deviceStats.sad -= (float)(updateDur / 48)
         self._deviceStats.Save()
-        print(self.getJson())
         
 
     def getJson(self):

+ 2 - 0
Trixy.pyproj

@@ -36,6 +36,7 @@
     <Compile Include="MicCapture\WindowsCapture.py" />
     <Compile Include="MicCapture\__init__.py" />
     <Compile Include="mods\BaseMod.py" />
+    <Compile Include="mods\NanoTTSMod\__init__.py" />
     <Compile Include="mods\WindowsSay\__init__.py" />
     <Compile Include="mods\ModPlaySound\__init__.py" />
     <Compile Include="OpenWeatherMap\WeatherData.py" />
@@ -95,6 +96,7 @@
     <Folder Include="cache\" />
     <Folder Include="config\" />
     <Folder Include="mods\ModPlaySound\" />
+    <Folder Include="mods\NanoTTSMod\" />
     <Folder Include="mods\WindowsSay\" />
     <Folder Include="ressources\texts\" />
     <Folder Include="test\" />

+ 1 - 1
main.py

@@ -22,7 +22,7 @@ if __name__ == "__main__":
     mod.execute("PlaySound", "welcome.mp3", False)
     print("Sound playing...")
 
-    joke = textauswahl.getInstance().executeText("test",["joke","kurzwitz"])
+    joke = textauswahl.getInstance().executeText("test",["joke","kurzwitz","boomerang"])
     print(joke)
     speach.getInstance().Say(joke)
 

+ 1 - 1
mods/BaseMod.py

@@ -5,7 +5,7 @@ from Stats import Stats as st
 
 class BaseMod:
     
-    def IsActive(self):
+    def IsActive(self) -> bool:
         return True
 
     @property

+ 0 - 4
mods/ModPlaySound/__init__.py

@@ -15,10 +15,6 @@ class ModPlaySound(BaseMod):
     def __init__(self):
         self._audio = pyaudio.PyAudio()
 
-
-    def IsActive(self):
-        return True
-
     def __del__(self):
         self._audio.terminate()
 

+ 9 - 5
mods/WindowsSay/__init__.py

@@ -2,23 +2,27 @@
 # -*- coding: utf-8 -*-
 from mods.BaseMod import BaseMod
 import os
-import win32com.client
 import platform
 
 class WindowsSay(BaseMod):
 
+    _isActive:bool=True
+    speaker=None
     def __init__(self):
         self.sys = platform.system()
         if self.sys=="Windows":
-            self.speaker = win32com.client.Dispatch("SAPI.SpVoice")
+            self._isActive=True
         else:
-            self.speaker = None
+            self._isActive=False
 
 
-    def IsActive(self):
-        return self.speaker!=None
+    def IsActive(self) -> bool:
+        return self._isActive
 
     def onSay(self, text):
+        import win32com.client
+        if self.speaker == None:
+            self.speaker = win32com.client.Dispatch("SAPI.SpVoice")
         if self.speaker != None:
             self.speaker.Rate = 0.0
             self.speaker.Speak(text)

+ 2 - 2
ressources/texts/test.json

@@ -196,12 +196,12 @@
     ]
   },
   {
-    "tags": [ "!joke", "kurzwitz" ],
+    "tags": [ "!joke", "kurzwitz","boomerang" ],
     "mood_add": {
       "funny": 10
     },
     "text": [
-      "Wie nennt man einen {object_nicer} Bumerang der nicht zurück kommt? Stock"
+      "Wie nennt man einen {object_nicer|en} Bumerang der nicht zurück kommt? Stock!"
     ]
   },
   {