快速入门

本页面显示了如何执行特定于 Cloud Healthcare API 口录模式的基本操作。

准备工作

有关 Cloud Healthcare API 的一般快速入门,请点击此处。以下说明假设您已完成本快速入门中的项目设置步骤。

存储和检索口录数据

  1. 为您的口录存储区选择一个名称:
  2. DICTATIONSTORE=mydictationstore
  3. 在数据集内创建口录存储区:
  4. curl -X POST --data '{"trainingConsent":"ALLOW"}' \
        https://healthcare.googleapis.com/v1alpha2/projects/${PROJECT_ID?}/locations/${LOCATION?}/datasets/${DATASET?}/dictationStores?access_token=${TOKEN?}\&dictation_store_id=${DICTATIONSTORE?}
  5. 将口录插入口录存储区中:
  6. curl -H "Content-Type: application/json" -X POST --data \
        '{"name":"dictation1", "audio":{"uri":"gs://dictations/speech/DrJohnson.flac"}}' \
        https://healthcare.googleapis.com/v1alpha2/projects/${PROJECT_ID?}/locations/${LOCATION?}/datasets/${DATASET?}/dictationStores/${DICTATIONSTORE?}/dictations?access_token=${TOKEN?}\&return_mask=name

配置并执行语音识别

  1. 将描述语音识别参数的 SpeechConfig 对象和与从 3 的口录语音匹配的文件格式插入口录存储区(此对象可以重复用于多个口录):
  2. curl -H "Content-Type: application/json" -X POST --data \
        '{"name":"speechConfig1", "recognition_config":{"encoding":"FLAC", "sampleRateHertz":"16000"},"speakerHumanName":"Jeremy"}' \
        https://healthcare.googleapis.com/v1alpha2/projects/${PROJECT_ID?}/locations/${LOCATION?}/datasets/${DATASET?}/dictationStores/${DICTATIONSTORE?}/speechConfigs?access_token=${TOKEN?}
  3. 从上面的方法调用中调用口录和 SpeechConfig 的记录 ID。以下 ID 仅作为示例提供 - 它们替换为创建口录和 SpeechSpeech 的调用中获得的 ID。
  4. DICTATION_ID=63411d4f-7d36-491f-9ed4-424786fa64d9
    SPEECHCONFIG_ID=9235fa21-0180-4efc-b033-306b0e187335
  5. 执行语音识别操作:
  6. curl -H "Content-Type: application/json" -X POST  --data \
        '{"speechConfigName":"projects/'${PROJECT_ID?}'/locations/'${LOCATION?}'/datasets/'${DATASET?}'/dictationStores/'${DICTATIONSTORE}'/speechConfigs/'${SPEECHCONFIG_ID}'"}' \
        https://healthcare.googleapis.com/v1alpha2/projects/${PROJECT_ID?}/locations/${LOCATION?}/datasets/${DATASET?}/dictationStores/${DICTATIONSTORE}/dictations/${DICTATION_ID?}:recognize?access_token=${TOKEN?}

后续步骤

查看文档