Browse Source

Fine tuning convert from opus :
- converted is silent now
- displayed file in logs name is the original one.

Jean-Francois Burdet 6 years ago
parent
commit
85486949cf
1 changed files with 5 additions and 4 deletions
  1. 5 4
      lenny.py

+ 5 - 4
lenny.py

@@ -80,7 +80,7 @@ class RepliesFactory(object):
     @staticmethod
     def convert_from_opus(opus_fname):
         wav_file = tempfile.NamedTemporaryFile(delete=False, suffix=".wav").name
-        subprocess.call("opusdec " + opus_fname + " " + wav_file, shell=True)
+        subprocess.call("opusdec --quiet " + opus_fname + " " + wav_file, shell=True)
         return wav_file
 
     def next(self):
@@ -95,10 +95,11 @@ class RepliesFactory(object):
             result = random.choice(self._random_replies)
             self._random_replies.remove(result)
 
+        original_file = result
         result = self.convert_from_opus(result)
 
         self._latest = result
-        return result
+        return result, original_file
 
 
 class ConversationStatus(Enum):
@@ -164,10 +165,10 @@ class SipConnection(object):
         if self._conversation.status is not ConversationStatus.IMTALKING:
             self._conversation.status = ConversationStatus.IMTALKING
 
-            voice_filename = self._replies.next()
+            voice_filename, original_file = self._replies.next()
 
             duration = get_wav_duration(voice_filename)
-            self.log("Saying : " + voice_filename)
+            self.log("Saying : " + original_file)
 
             core.play_file = voice_filename