コード例 #1
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def do_command(self, action):
     if self.ready:
         action = str(action)
         self.baresip.sendline(action)
     else:
         LOG.warning(action + " not executed!")
         LOG.error("NOT READY! please wait")
コード例 #2
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def speak(self, speech):
     if not self.call_established:
         LOG.error("Speaking without an active call!")
     else:
         LOG.info("Sending TTS for " + speech)
         self.send_audio(self.tts.get_mp3(speech))
         sleep(0.5)
コード例 #3
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def hang(self):
     if self.current_call:
         LOG.info("Hanging: " + self.current_call)
         self.do_command("/hangup")
         self.current_call = None
         self._call_status = None
     else:
         LOG.error("No active call to hang")
コード例 #4
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def mute_mic(self):
     if not self.call_established:
         LOG.error("Can not mute microphone while not in a call")
         return
     if not self.mic_muted:
         LOG.info("Muting mic")
         self.do_command("/mute")
     else:
         LOG.info("Mic already muted")
コード例 #5
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def send_dtmf(self, number):
     number = str(number)
     for n in number:
         if n not in "0123456789":
             LOG.error("invalid dtmf tone")
             return
     LOG.info("Sending dtmf tones for " + number)
     dtmf = join(tempfile.gettempdir(), number + ".wav")
     ToneGenerator().dtmf_to_wave(number, dtmf)
     self.send_audio(dtmf)
コード例 #6
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def send_audio(self, wav_file):
     if not self.call_established:
         LOG.error("Can't send audio without an active call!")
         return
     wav_file, duration = self.convert_audio(wav_file)
     # send audio stream
     LOG.info("transmitting audio")
     self.do_command("/ausrc aufile," + wav_file)
     # wait till playback ends
     sleep(duration - 0.5)
     # avoid baresip exiting
     self.do_command("/ausrc alsa,default")
コード例 #7
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def resume(self):
     if self.current_call:
         LOG.info("Resuming " + self.current_call)
         self.do_command("/resume")
     else:
         LOG.error("No active call to resume")
コード例 #8
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def hold(self):
     if self.current_call:
         LOG.info("Holding: " + self.current_call)
         self.do_command("/hold")
     else:
         LOG.error("No active call to hold")
コード例 #9
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def handle_error(self, error):
     LOG.error(error)
     if error == "failed to set audio-source (No such device)":
         self.handle_audio_stream_failure()
コード例 #10
0
ファイル: __init__.py プロジェクト: marcushorwich/baresipy
 def handle_login_failure(self):
     LOG.error("Log in failed!")
     self.quit()