예제 #1
0
    def __init__(self, parent=None):
        super(MyWidget, self).__init__(parent)
        layout = QtGui.QVBoxLayout(self)
        self.xb_client = crossbarconnect.Client(PUBLISH_URL)

        self.inp1 = QtGui.QLineEdit("enter some text here")
        layout.addWidget(self.inp1)

        self.lab1 = QtGui.QLabel('---')
        layout.addWidget(self.lab1)

        self.btn1 = QtGui.QPushButton("publish event 1")
        layout.addWidget(self.btn1)
        self.btn1.pressed.connect(self._publish)

        self.inp2 = QtGui.QLineEdit("enter another text here")
        layout.addWidget(self.inp2)

        self.btn2 = QtGui.QPushButton("rpc call")
        layout.addWidget(self.btn2)
        self.btn2.pressed.connect(self._call)

        self.btn_quit = QtGui.QPushButton("Quit")
        layout.addWidget(self.btn_quit)
        self.btn_quit.pressed.connect(self._quit)

        logger.debug("now connecting signals")
        self.sig_subscribe_cb.connect(self.subscribe_callback)
        self.sig_quit.connect(self._quit)

        logger.info("widget created")
예제 #2
0
파일: mic.py 프로젝트: rab206/self-proj-pi
    def __init__(self, speaker, passive_stt_engine, active_stt_engine):
        """
        Initiates the pocketsphinx instance.
        Arguments:
        speaker -- handles platform-independent audio output
        passive_stt_engine -- performs STT while Jasper is in passive listen
                              mode
        acive_stt_engine -- performs STT while Jasper is in active listen mode
        """
        self._logger = logging.getLogger(__name__)
        self.speaker = speaker
        self.passive_stt_engine = passive_stt_engine
        self.active_stt_engine = active_stt_engine
	self._logger.warning("about to connect to pyaudio")
        self._audio = pyaudio.PyAudio()
        self.client = crossbarconnect.Client("http://127.0.0.1:8080/publish")
        self._logger.warning("websocket connected")
	profile_path = jasperpath.config('profile.yml')
        if os.path.exists(profile_path):
            with open(profile_path, 'r') as f:
                profile = yaml.safe_load(f)
                if 'witai-stt' in profile:
                    if 'access_token' in profile['witai-stt']:
                        self.token = profile['witai-stt']['access_token']
예제 #3
0
##  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
##  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
##  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
##  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
##  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
##  POSSIBILITY OF SUCH DAMAGE.
##
###############################################################################

import crossbarconnect

if __name__ == '__main__':

    ## create a new Crossbar.io push client (once)
    ##
    client = crossbarconnect.Client("http://127.0.0.1:8080/push")

    ## publish an event without payload
    ##
    client.publish("com.myapp.topic1")

    ## publish an event with (positional) payload and get publication ID
    ##
    event_id = client.publish("com.myapp.topic1", "Hello, world!", 23)
    print("event published with ID {0}".format(event_id))

    ## publish 5 events with complex payload
    ##
    for i in range(5):
        client.publish("com.myapp.topic1", i, sq=i * i, msg="Hello, world!")
##  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
##  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
##  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
##  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
##  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
##  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
##  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
##  POSSIBILITY OF SUCH DAMAGE.
##
###############################################################################

import ssl
import crossbarconnect

if __name__ == '__main__':
    # Create a new Crossbar.io push client (once), providing key/secret
    #
    context = ssl._create_unverified_context(
    )  # we're using self-signed certs, so disable cert checking
    client = crossbarconnect.Client("https://127.0.0.1:8080/publish-signed",
                                    key="foobar",
                                    secret="secret",
                                    context=context)

    # Publish an event with (positional) payload and get publication ID
    # Since we provided key/secret before, the request will be signed.
    #
    event_id = client.publish("com.myapp.topic1", "Hello, world!", 23)

    print("event published with ID {0}".format(event_id))
예제 #5
0
##  you may not use this file except in compliance with the License.
##  You may obtain a copy of the License at
##
##      http://www.apache.org/licenses/LICENSE-2.0
##
##  Unless required by applicable law or agreed to in writing, software
##  distributed under the License is distributed on an "AS IS" BASIS,
##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##  See the License for the specific language governing permissions and
##  limitations under the License.
##
###############################################################################


import crossbarconnect


if __name__ == '__main__':

   ## create a new Crossbar.io push client (once), providing key/secret
   ## for signed requests
   ##
   client = crossbarconnect.Client("http://127.0.0.1:8080/push",
      key = "foobar", secret = "secret")

   ## publish an event without payload
   ##
   event_id = client.publish("com.myapp.topic1", "Hello, world!", 23)

   print("event published with ID {0}".format(event_id))
예제 #6
0
        router=WAMP_URL,
        realm=WAMP_REALM,
        topic=TOPIC_URI)


@app.route('/form1', methods=['POST'])
def form1_submit():
    """
   Extract data from a submitted HTML form, publish event via
   Crossbar.io HTTP Pusher service and render success page.
   """
    try:
        ## here we publish the form data via Crossbar.io HTTP Pusher service
        ## as a WAMP event to all subscribers on TOPIC_URI
        ##
        publication_id = app.pusher.publish(TOPIC_URI,
                                            name=request.form['name'],
                                            age=request.form['age'])
        return render_template('onsubmit.html', publication_id=publication_id)
    except Exception as e:
        return "Publication failed: {}".format(e)


if __name__ == "__main__":

    ## we create a client for pushing event via Crossbar.io
    app.pusher = crossbarconnect.Client(PUSH_URL)

    ## now run our Flask app
    app.run(debug=True)
예제 #7
0
##  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
##  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
##  POSSIBILITY OF SUCH DAMAGE.
##
###############################################################################

import ssl
import crossbarconnect

if __name__ == '__main__':

    # create a new Crossbar.io push client (once)
    #
    context = ssl._create_unverified_context(
    )  # we're using self-signed certs, so disable cert checking
    client = crossbarconnect.Client("https://127.0.0.1:8080/publish",
                                    context=context)

    # publish an event without payload
    #
    client.publish("com.myapp.topic1")

    # publish an event with (positional) payload and get publication ID
    #
    event_id = client.publish("com.myapp.topic1", "Hello, world!", 23)
    print("event published with ID {0}".format(event_id))

    # publish 5 events with complex payload
    #
    for i in range(5):
        client.publish("com.myapp.topic1", i, sq=i * i, msg="Hello, world!")