0 комментариев

Здравствуйте,надо результат распознанной команды от гугл ассистента отправить с помощью get запроса на сервер обработчик.

    #!/usr/bin/env python
    # Copyright (C) 2017 Google Inc.
    # Licensed under the Apache License, Version 2.0 (the "License");
    # 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.
    from __future__ import print_function
    import argparse
    import os.path
    import json
    import urllib
    import google.oauth2.credentials
    from google.assistant.library import Assistant
    from google.assistant.library.event import EventType
    from google.assistant.library.file_helpers import existing_file
    def process_event(event):
        """Pretty prints events.
        Prints all events that occur with two spaces between each new
        conversation and a single space between turns of a conversation.
        event(event.Event): The current event to process.
        if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and
            event.args and not event.args['with_follow_on_turn']):
        if event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED:
    #        isay = event.args['text']
            cmd = str(event.args['text'])
            isay = {'qry':cmd}
            current_url = '' % urllib.parse.urlencode(isay)
    #        isay = ('qry',event.args['text'])
    #        isay = object.__str__(event.args['text'])
    #        print('I listen: ', isay)
    #        current_url = '' % urllib.parse.urlencode(str(isay))
    #        current_url = '' % urllib.parse.quote(isay)
    #        urllib.urlopen(current_url)
    #        print('Command: ', current_url)
    def main():
        parser = argparse.ArgumentParser(
        parser.add_argument('--credentials', type=existing_file,
                help='Path to store and read OAuth2 credentials')
        args = parser.parse_args()
        with open(args.credentials, 'r') as f:
        credentials = google.oauth2.credentials.Credentials(token=None,
        with Assistant(credentials) as assistant:
        for event in assistant.start():
    if __name__ == '__main__':

В таком исполнении ругается:

TypeError: not all arguments converted during string formatting

Помогите пожалуйста исправить код.

Добавить комментарий