我很努力將Ruby雲語音API用於ruby客戶端(v0.22.2)。保存Google雲語音API操作(作業)對象以稍後檢索結果
我能夠執行長時間運行的工作,如果我用
job.wait_until_done!
可以得到的結果,但這種鎖定了什麼可以是很長一段時間的服務器。
根據API文檔,我真正需要的是操作名稱(id)。
有什麼辦法從操作名稱創建一個作業對象,並以這種方式檢索它? 我似乎無法創建一個功能新的工作對象,例如從@grpc_op
使用id我想要做的是一樣的東西:
speech = Google::Cloud::Speech.new(auth_credentials)
job = speech.recognize_job file, options
saved_job = job.to_json #Or some element of that object such that I can retrieve it.
Later, I want to do something like....
job_object = Google::Cloud::Speech::Job.new(saved_job)
job.reload!
job.done?
job.results
真的希望這對某人有意義。 基於一切似乎都被翻譯成比使用API所需的對象更復雜的對象的基礎上,與Google的Ruby客戶端苦苦掙扎。 有沒有我在這裏失蹤的一些詭計?
這看起來方便多了。 我的問題,對我來說可能是獨一無二的,升級是它會轉移到與我正在做的其他事情(我們通過api與驅動器和Gmail集成)不兼容的不同版本的Google API客戶端,而無需一整件重工。他說,這顯然是絕大多數情況下應該做的事情。 – Carpela
已更新,以顯示如何將功能更新到舊版本。 – blowmage
在這裏遇到一些問題。 首先,猴子補丁使用'語音'而沒有定義它,這導致了未定義的方法錯誤。 NameError:未定義的局部變量或方法'語音'爲# 其次,如果解決該問題,from_grpc方法只接受該版本中的一個參數圖書館。 因此,您無法將speech.service對象傳遞給它。 ArgumentError:錯誤的參數數量(給定2,預計1) from .../vendor/bundle/gems/google-cloud-speech-0.22.2/lib/google/cloud/speech/job.rb: 151:在'from_grpc' –
Carpela