Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Google Assistant Library for Python
- google.assistant.library package.
- class google.assistant.library.Assistant(credentials)[source]
- Client for the Google Assistant Library.
- Provides basic control functionality and lifecycle handling for the Google Assistant.
- Google Assistantの基本的な制御機能とライフサイクル処理を提供します。
- It is best practice to use the Assistant as a ContextManager:
- アシスタントをContextManagerとして使用することをお勧めします。
- with Assistant(credentials) as assistant:
- This allows the underlying native implementation to properly handle memory management.
- これにより、基本となるネイティブ実装がメモリ管理を適切に処理できるようになります。
- Once started, the Assistant generates a stream of Events relaying the various states the Assistant is currently in, for example:
- アシスタントが起動すると、アシスタントが現在いるさまざまな状態を中継するイベントストリームが生成されます。たとえば、次のようになります。
- ON_CONVERSATION_TURN_STARTED
- ON_END_OF_UTTERANCE
- ON_RECOGNIZING_SPEECH_FINISHED
- {'text': 'what time is it'}
- ON_RESPONDING_STARTED:
- {'is_error_response': False}
- ON_RESPONDING_FINISHED
- ON_CONVERSATION_TURN_FINISHED
- {'with_follow_on_turn': False}
- See google.assistant.event.EventType for details on all events and their arguments.
- Glossary:
- Hotword: The phrase the Assistant listens for when not muted:
- ホットワード:アシスタントがミュートされていないときに聴くフレーズ:
- Ok Google OR Hey Google
- Turn: A single user request followed by a response from the Assistant.
- ターン:単一のユーザー要求とそれに続くアシスタントからの応答。
- Conversation: One or more turns which result in a desired final result from the Assistant:
- 会話:アシスタントからの最終的な結果が得られる1回以上の回:
- What time is it? -> The time is 6:24 PM
- OR
- Set a timer -> Okay, for how long? ->
- 5 minutes -> Sure, 5 minutes, starting now!
- set_mic_mute(is_muted)[source]
- Stops the Assistant from listening for the hotword.
- アシスタントがホットワードを聞くのを停止します。
- Allows for disabling the Assistant from listening for the hotword.
- アシスタントがホットワードを聞き取れないようにすることができます。
- This provides functionality similar to the privacy button on the back of Google Home.
- これにより、Googleホームの背面にあるプライバシーボタンと同様の機能が提供されます。
- This method is a no-op if the Assistant has not yet been started.
- アシスタントがまだ開始されていない場合、このメソッドはno-opです。
- Args:
- is_muted(bool): True stops the Assistant from listening and False allows it to start again.
- is_muted(ブール値):アシスタントがリッスンを停止し、Falseを指定するとリスンが再び開始されます。
- start()[source]
- Starts the Assistant, which includes listening for a hotword.
- アシスタントを開始します。アシスタントには、ホットワードを聞くことが含まれます。
- Once start() is called, the Assistant will begin processing data from the ‘default’ ALSA audio source, listening for the hotword.
- start()が呼び出されると、アシスタントは 'デフォルト'のALSAオーディオソースからのデータの処理を開始し、ホットワードをリッスンします
- This will also start other services provided by the Assistant, such as timers/alarms.
- また、タイマーやアラームなど、アシスタントによって提供されるその他のサービスも開始されます。
- This method can only be called once.
- このメソッドは1回だけ呼び出すことができます。
- Once called, the Assistant will continue to run until __exit__ is called.
- 呼び出されると、アシスタントは__exit__が呼び出されるまで実行を続けます。
- Returns:
- google.assistant.event.IterableEventQueue: A queue of events that notify of changes to the Assistant state.
- アシスタント状態への変更を通知するイベントのキュー。
- start_conversation()[source]
- Manually starts a new conversation with the Assistant.
- アシスタントで新しい会話を手動で開始します。
- Starts both recording the user’s speech and sending it to Google, similar to what happens when the Assistant hears the hotword.
- アシスタントがホットワードを聞いたときと同じように、ユーザーの音声を録音してGoogleに送信します。
- This method is a no-op if the Assistant is not started or has been muted.
- アシスタントが開始されていないか、ミュートされている場合、このメソッドはノーオペレーションです。
- stop_conversation()[source]
- Stops any active conversation with the Assistant.
- アシスタントでアクティブな会話をすべて停止します。
- The Assistant could be listening to the user’s query OR responding. If there is no active conversation, this is a no-op.
- version
- Returns the version of the Assistant.
- アシスタントのバージョンを返します。
- Returns:
- dict: Contains the version of the Assistant being used.
- 使用されているアシスタントのバージョンが含まれます。
- class google.assistant.library.event.Event(event_type, args)[source]
- An event generated by the Assistant.
- アシスタントによって生成されたイベント。
- Attributes:
- type(EventType): The type of event that was generated.
- 生成されたイベントのタイプ。
- args(dict): Argument key/value pairs associated with this event.
- このイベントに関連付けられたキー/値の組み合わせを引数として取ります。
- class google.assistant.library.event.EventType[source]
- ON_START_FINISHED = 0
- The Assistant library has finished starting.
- アシスタントライブラリの起動が完了しました。
- ON_CONVERSATION_TURN_STARTED = 1
- Indicates a new turn has started.
- 新しいターンが開始されたことを示します。
- The Assistant is currently listening, waiting for a user query.
- アシスタントは現在、ユーザーの問い合わせを待機しています。
- This could be the result of hearing the hotword or start_conversation() being called on the Assistant.
- これは、アシスタントに対して呼び出されたホットワードまたはstart_conversation()を聞いた結果である可能性があります。
- ON_CONVERSATION_TURN_TIMEOUT = 2
- The Assistant timed out waiting for a discernable query.
- アシスタントは、識別可能なクエリを待ってタイムアウトしました。
- This could be caused by a mistrigger of the Hotword or the Assistant could not understand what the user said.
- これは、ホットワードの誤解によって引き起こされる可能性があります。または、アシスタントがユーザーの発言を理解できませんでした。
- ON_END_OF_UTTERANCE = 3
- The Assistant has stopped listening to a user query.
- アシスタントはユーザークエリのリッスンを停止しました。
- The Assistant may not have finished figuring out what the user has said but it has stopped listening for more audio data.
- アシスタントは、ユーザーが何を言っているのか把握していないかもしれませんが、それ以上のオーディオデータの受信を停止しています。
- ON_RECOGNIZING_SPEECH_FINISHED = 5
- The Assistant has determined the final recognized speech.
- アシスタントは最終的に認識された音声を決定しました。
- Args:
- text(str): The final text interpretation of a user’s query.
- ユーザーのクエリの最終的なテキスト解釈。
- ON_RESPONDING_STARTED = 6
- The Assistant is starting to respond by voice.
- アシスタントは声で応答し始めています。
- The Assistant will be responding until ON_RESPONDING_FINISHED is received.
- アシスタントは、ON_RESPONDING_FINISHEDが受信されるまで応答します。
- Args:
- is_error_response(bool): True means a local error TTS is being played, otherwise the Assistant responds with a server response.
- TrueはローカルエラーTTSが再生されていることを意味し、そうでない場合はアシスタントがサーバーレスポンスで応答します。
- ON_RESPONDING_FINISHED = 7
- The Assistant has finished responding by voice.
- ON_NO_RESPONSE = 8
- The Assistant successfully completed its turn but has nothing to say.
- アシスタントはターンを正常に終了しましたが、何も言いません。
- ON_CONVERSATION_TURN_FINISHED = 9
- The Assistant finished the current turn.
- アシスタントは現在のターンを終了しました。
- This includes both processing a user’s query and speaking the full response.
- これには、ユーザーのクエリの処理と完全な応答のスピーチの両方が含まれます。
- Args:
- with_follow_on_turn(bool): If True, the Assistant is expecting a follow up interaction from the user.
- Trueの場合、アシスタントはユーザーからのフォローアップ対話を期待しています。
- The microphone will be re-opened to allow the user to answer a follow-up question.
- マイクは、ユーザーがフォローアップの質問に答えるために再開されます。
- ON_ALERT_STARTED = 10
- Indicates that an alert has started sounding.
- アラートが鳴り始めたことを示します。
- This alert will continue until ON_ALERT_FINISHED with the same alert_type is received.
- このアラートは、同じalert_typeを持つON_ALERT_FINISHEDが受信されるまで続きます。
- Only one alert should be active at any given time.
- 一度に1つのアラートのみアクティブにする必要があります。
- Args:
- alert_type(int): The id of the Enum representing the currently sounding type of alert.
- アラートの現在のタイプを表すEnumのID。
- ON_ALERT_FINISHED = 11
- Indicates the alert of alert_type has finished sounding.
- alert_typeのアラートが終了したことを示します。
- Args:
- alert_type(int): The id of the Enum representing the type of alert which just finished.
- 最後に完了したアラートのタイプを表すEnumのIDです。
- ON_ASSISTANT_ERROR = 12
- Indicates if the Assistant library has encountered an error.
- アシスタントライブラリにエラーが発生したかどうかを示します。
- Args:
- is_fatal(bool): If True then the Assistant will be unable to recover and should be restarted.
- Trueの場合、アシスタントは回復できなくなり、再起動する必要があります。
- ON_MUTED_CHANGED = 13
- Indicates that the Assistant is currently listening or not.
- アシスタントが現在リッスンしているかどうかを示します。
- start() will always generate an ON_MUTED_CHANGED to report the initial value.
- start()は常にON_MUTED_CHANGEDを生成して初期値を報告します。
- Args:
- is_muted(bool): If True then the Assistant is not currently listening for its hotword and will not respond to user queries.
- is_muted(bool):アシスタントは現在、そのホットワードをリッスンしておらず、ユーザーのクエリに応答しません。
- class google.assistant.library.event.AlertType[source]
- ALARM = 0
- An event set for an absolute time such as ‘3 A.M on Monday’
- 「月曜日に3 A.M」のような絶対時間のイベントセットは、
- TIMER = 1
- An event set for a relative time such as ‘30 seconds from now.’
- 「今から30秒」などの相対時間に設定されたイベント。
- class google.assistant.library.event.IterableEventQueue(timeout=3600)[source]
- Extends queue.Queue to add an __iter__ interface.
- Queueueを拡張し、__iter__インターフェースを追加します。
- offer(event)[source]
- Offer an event to put in the queue.
- キューに入れるイベントを提供する。
- If the queue is currently full the event will be logged but not added.
- 現在キューがいっぱいの場合、イベントは記録されますが追加されません。
- Args:
- event(Event): The event to try to add to the queue.
- キューに追加しようとするイベント。
Add Comment
Please, Sign In to add comment