簡體   English   中英

是否可以從終端捕獲 Android google-voice-typing 的文本 output?

[英]Is it possible to capture the text output of an Android google-voice-typing from terminal?

假設我想使用我的智能手機的麥克風在我的終端中輸入文本,使用 google voice2speech 引擎。 我該怎么辦?

我會先聽 output 的google-voice-typing ,(但如何?)然后重定向到stdin

adb命令有簡單的方法嗎?

您可以使用AndroidViewClient/culebra

  1. 找到谷歌快速搜索框
  2. 點擊麥克風圖標
  3. 提示用戶說些什么
  4. 找到搜索結果
  5. 打印文本
#! /usr/bin/env python3


from com.dtmilano.android.viewclient import ViewClient

helper = ViewClient.view_client_helper()

# mic in voice search widget
obj_ref = helper.until.find_object(body={
    'clazz': 'android.widget.ImageButton',
    'clickable': True,
    'desc': 'Voice Search'
})
response = helper.ui_device.wait(oid=obj_ref.oid)
helper.ui_object2.click(oid=response['oid'])
print('Speak now...')
helper.ui_device.wait_for_window_update()

# text in search results
obj_ref = helper.until.find_object(body={
    'res': 'com.google.android.googlequicksearchbox:id/googleapp_srp_search_box_text',
    'clazz': 'android.widget.TextView'
})
response = helper.ui_device.wait(oid=obj_ref.oid)
print('Text:')
print(helper.ui_object2.get_text(oid=response['oid']).text)

output 會是這樣的

Speak now...
Text:
this is another example

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM