Guest User

Untitled

a guest
Nov 18th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.99 KB | None | 0 0
  1. Google Assistant Library for Python
  2.  
  3. google.assistant.library package.
  4.  
  5. class google.assistant.library.Assistant(credentials)[source]
  6. Client for the Google Assistant Library.
  7.  
  8. Provides basic control functionality and lifecycle handling for the Google Assistant.
  9. Google Assistantの基本的な制御機能とライフサイクル処理を提供します。
  10.  
  11. It is best practice to use the Assistant as a ContextManager:
  12. アシスタントをContextManagerとして使用することをお勧めします。
  13.  
  14. with Assistant(credentials) as assistant:
  15.  
  16. This allows the underlying native implementation to properly handle memory management.
  17. これにより、基本となるネイティブ実装がメモリ管理を適切に処理できるようになります。
  18.  
  19. Once started, the Assistant generates a stream of Events relaying the various states the Assistant is currently in, for example:
  20. アシスタントが起動すると、アシスタントが現在いるさまざまな状態を中継するイベントストリームが生成されます。たとえば、次のようになります。
  21.  
  22. ON_CONVERSATION_TURN_STARTED
  23. ON_END_OF_UTTERANCE
  24. ON_RECOGNIZING_SPEECH_FINISHED
  25. {'text': 'what time is it'}
  26. ON_RESPONDING_STARTED:
  27. {'is_error_response': False}
  28. ON_RESPONDING_FINISHED
  29. ON_CONVERSATION_TURN_FINISHED
  30. {'with_follow_on_turn': False}
  31. See google.assistant.event.EventType for details on all events and their arguments.
  32.  
  33. Glossary:
  34. Hotword: The phrase the Assistant listens for when not muted:
  35. ホットワード:アシスタントがミュートされていないときに聴くフレーズ:
  36. Ok Google OR Hey Google
  37. Turn: A single user request followed by a response from the Assistant.
  38. ターン:単一のユーザー要求とそれに続くアシスタントからの応答。
  39.  
  40. Conversation: One or more turns which result in a desired final result from the Assistant:
  41. 会話:アシスタントからの最終的な結果が得られる1回以上の回:
  42. What time is it? -> The time is 6:24 PM
  43. OR
  44. Set a timer -> Okay, for how long? ->
  45. 5 minutes -> Sure, 5 minutes, starting now!
  46.  
  47. set_mic_mute(is_muted)[source]
  48. Stops the Assistant from listening for the hotword.
  49. アシスタントがホットワードを聞くのを停止します。
  50.  
  51. Allows for disabling the Assistant from listening for the hotword.
  52. アシスタントがホットワードを聞き取れないようにすることができます。
  53.  
  54. This provides functionality similar to the privacy button on the back of Google Home.
  55. これにより、Googleホームの背面にあるプライバシーボタンと同様の機能が提供されます。
  56.  
  57. This method is a no-op if the Assistant has not yet been started.
  58. アシスタントがまだ開始されていない場合、このメソッドはno-opです。
  59.  
  60. Args:
  61. is_muted(bool): True stops the Assistant from listening and False allows it to start again.
  62. is_muted(ブール値):アシスタントがリッスンを停止し、Falseを指定するとリスンが再び開始されます。
  63.  
  64. start()[source]
  65. Starts the Assistant, which includes listening for a hotword.
  66. アシスタントを開始します。アシスタントには、ホットワードを聞くことが含まれます。
  67.  
  68. Once start() is called, the Assistant will begin processing data from the ‘default’ ALSA audio source, listening for the hotword.
  69. start()が呼び出されると、アシスタントは 'デフォルト'のALSAオーディオソースからのデータの処理を開始し、ホットワードをリッスンします
  70.  
  71. This will also start other services provided by the Assistant, such as timers/alarms.
  72. また、タイマーやアラームなど、アシスタントによって提供されるその他のサービスも開始されます。
  73.  
  74. This method can only be called once.
  75. このメソッドは1回だけ呼び出すことができます。
  76.  
  77. Once called, the Assistant will continue to run until __exit__ is called.
  78. 呼び出されると、アシスタントは__exit__が呼び出されるまで実行を続けます。
  79.  
  80. Returns:
  81. google.assistant.event.IterableEventQueue: A queue of events that notify of changes to the Assistant state.
  82. アシスタント状態への変更を通知するイベントのキュー。
  83.  
  84. start_conversation()[source]
  85. Manually starts a new conversation with the Assistant.
  86. アシスタントで新しい会話を手動で開始します。
  87.  
  88. Starts both recording the user’s speech and sending it to Google, similar to what happens when the Assistant hears the hotword.
  89. アシスタントがホットワードを聞いたときと同じように、ユーザーの音声を録音してGoogleに送信します。
  90.  
  91. This method is a no-op if the Assistant is not started or has been muted.
  92. アシスタントが開始されていないか、ミュートされている場合、このメソッドはノーオペレーションです。
  93.  
  94.  
  95. stop_conversation()[source]
  96. Stops any active conversation with the Assistant.
  97. アシスタントでアクティブな会話をすべて停止します。
  98.  
  99. The Assistant could be listening to the user’s query OR responding. If there is no active conversation, this is a no-op.
  100.  
  101. version
  102. Returns the version of the Assistant.
  103. アシスタントのバージョンを返します。
  104.  
  105. Returns:
  106. dict: Contains the version of the Assistant being used.
  107. 使用されているアシスタントのバージョンが含まれます。
  108.  
  109. class google.assistant.library.event.Event(event_type, args)[source]
  110. An event generated by the Assistant.
  111. アシスタントによって生成されたイベント。
  112.  
  113. Attributes:
  114. type(EventType): The type of event that was generated.
  115. 生成されたイベントのタイプ。
  116. args(dict): Argument key/value pairs associated with this event.
  117. このイベントに関連付けられたキー/値の組み合わせを引数として取ります。
  118.  
  119. class google.assistant.library.event.EventType[source]
  120. ON_START_FINISHED = 0
  121. The Assistant library has finished starting.
  122. アシスタントライブラリの起動が完了しました。
  123.  
  124. ON_CONVERSATION_TURN_STARTED = 1
  125. Indicates a new turn has started.
  126. 新しいターンが開始されたことを示します。
  127.  
  128. The Assistant is currently listening, waiting for a user query.
  129. アシスタントは現在、ユーザーの問い合わせを待機しています。
  130.  
  131. This could be the result of hearing the hotword or start_conversation() being called on the Assistant.
  132. これは、アシスタントに対して呼び出されたホットワードまたはstart_conversation()を聞いた結果である可能性があります。
  133.  
  134. ON_CONVERSATION_TURN_TIMEOUT = 2
  135. The Assistant timed out waiting for a discernable query.
  136. アシスタントは、識別可能なクエリを待ってタイムアウトしました。
  137.  
  138. This could be caused by a mistrigger of the Hotword or the Assistant could not understand what the user said.
  139. これは、ホットワードの誤解によって引き起こされる可能性があります。または、アシスタントがユーザーの発言を理解できませんでした。
  140.  
  141. ON_END_OF_UTTERANCE = 3
  142. The Assistant has stopped listening to a user query.
  143. アシスタントはユーザークエリのリッスンを停止しました。
  144.  
  145. The Assistant may not have finished figuring out what the user has said but it has stopped listening for more audio data.
  146. アシスタントは、ユーザーが何を言っているのか把握していないかもしれませんが、それ以上のオーディオデータの受信を停止しています。
  147.  
  148. ON_RECOGNIZING_SPEECH_FINISHED = 5
  149. The Assistant has determined the final recognized speech.
  150. アシスタントは最終的に認識された音声を決定しました。
  151.  
  152. Args:
  153. text(str): The final text interpretation of a user’s query.
  154. ユーザーのクエリの最終的なテキスト解釈。
  155.  
  156. ON_RESPONDING_STARTED = 6
  157. The Assistant is starting to respond by voice.
  158. アシスタントは声で応答し始めています。
  159.  
  160. The Assistant will be responding until ON_RESPONDING_FINISHED is received.
  161. アシスタントは、ON_RESPONDING_FINISHEDが受信されるまで応答します。
  162.  
  163. Args:
  164. is_error_response(bool): True means a local error TTS is being played, otherwise the Assistant responds with a server response.
  165. TrueはローカルエラーTTSが再生されていることを意味し、そうでない場合はアシスタントがサーバーレスポンスで応答します。
  166.  
  167. ON_RESPONDING_FINISHED = 7
  168. The Assistant has finished responding by voice.
  169.  
  170. ON_NO_RESPONSE = 8
  171. The Assistant successfully completed its turn but has nothing to say.
  172. アシスタントはターンを正常に終了しましたが、何も言いません。
  173.  
  174. ON_CONVERSATION_TURN_FINISHED = 9
  175. The Assistant finished the current turn.
  176. アシスタントは現在のターンを終了しました。
  177.  
  178. This includes both processing a user’s query and speaking the full response.
  179. これには、ユーザーのクエリの処理と完全な応答のスピーチの両方が含まれます。
  180.  
  181. Args:
  182. with_follow_on_turn(bool): If True, the Assistant is expecting a follow up interaction from the user.
  183. Trueの場合、アシスタントはユーザーからのフォローアップ対話を期待しています。
  184. The microphone will be re-opened to allow the user to answer a follow-up question.
  185. マイクは、ユーザーがフォローアップの質問に答えるために再開されます。
  186.  
  187. ON_ALERT_STARTED = 10
  188. Indicates that an alert has started sounding.
  189. アラートが鳴り始めたことを示します。
  190.  
  191. This alert will continue until ON_ALERT_FINISHED with the same alert_type is received.
  192. このアラートは、同じalert_typeを持つON_ALERT_FINISHEDが受信されるまで続きます。
  193.  
  194. Only one alert should be active at any given time.
  195. 一度に1つのアラートのみアクティブにする必要があります。
  196. Args:
  197. alert_type(int): The id of the Enum representing the currently sounding type of alert.
  198. アラートの現在のタイプを表すEnumのID。
  199.  
  200. ON_ALERT_FINISHED = 11
  201. Indicates the alert of alert_type has finished sounding.
  202. alert_typeのアラートが終了したことを示します。
  203.  
  204. Args:
  205. alert_type(int): The id of the Enum representing the type of alert which just finished.
  206. 最後に完了したアラートのタイプを表すEnumのIDです。
  207.  
  208. ON_ASSISTANT_ERROR = 12
  209. Indicates if the Assistant library has encountered an error.
  210. アシスタントライブラリにエラーが発生したかどうかを示します。
  211.  
  212. Args:
  213. is_fatal(bool): If True then the Assistant will be unable to recover and should be restarted.
  214. Trueの場合、アシスタントは回復できなくなり、再起動する必要があります。
  215.  
  216. ON_MUTED_CHANGED = 13
  217. Indicates that the Assistant is currently listening or not.
  218. アシスタントが現在リッスンしているかどうかを示します。
  219.  
  220. start() will always generate an ON_MUTED_CHANGED to report the initial value.
  221. start()は常にON_MUTED_CHANGEDを生成して初期値を報告します。
  222.  
  223. Args:
  224. is_muted(bool): If True then the Assistant is not currently listening for its hotword and will not respond to user queries.
  225. is_muted(bool):アシスタントは現在、そのホットワードをリッスンしておらず、ユーザーのクエリに応答しません。
  226.  
  227. class google.assistant.library.event.AlertType[source]
  228. ALARM = 0
  229. An event set for an absolute time such as ‘3 A.M on Monday’
  230. 「月曜日に3 A.M」のような絶対時間のイベントセットは、
  231. TIMER = 1
  232. An event set for a relative time such as ‘30 seconds from now.’
  233. 「今から30秒」などの相対時間に設定されたイベント。
  234.  
  235. class google.assistant.library.event.IterableEventQueue(timeout=3600)[source]
  236. Extends queue.Queue to add an __iter__ interface.
  237. Queueueを拡張し、__iter__インターフェースを追加します。
  238.  
  239. offer(event)[source]
  240. Offer an event to put in the queue.
  241. キューに入れるイベントを提供する。
  242.  
  243. If the queue is currently full the event will be logged but not added.
  244. 現在キューがいっぱいの場合、イベントは記録されますが追加されません。
  245.  
  246. Args:
  247. event(Event): The event to try to add to the queue.
  248. キューに追加しようとするイベント。
Add Comment
Please, Sign In to add comment