GSpeechDuplex.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:SpeechRaspberrySmartHouse 作者:
/**
 * This method allows you to stream a continuous stream of data to the API.
 * <p>
 * Note: This feature is experimental.</p>
 *
 * @param tl
 * @param af
 * @throws IOException
 * @throws LineUnavailableException
 */
public void recognize(TargetDataLine tl, AudioFormat af) throws IOException, LineUnavailableException {
    //Generates a unique ID for the response. 
    final long PAIR = MIN + (long) (Math.random() * ((MAX - MIN) + 1L));

    //Generates the Downstream URL
    final String API_DOWN_URL = GOOGLE_DUPLEX_SPEECH_BASE + "down?maxresults=1&pair=" + PAIR;

    //Generates the Upstream URL
    final String API_UP_URL = GOOGLE_DUPLEX_SPEECH_BASE
            + "up?lang=" + language + "&lm=dictation&client=chromium&pair=" + PAIR
            + "&key=" + API_KEY + "&continuous=true&interim=true"; //Tells Google to constantly monitor the stream;

    //Opens downChannel
    this.downChannel(API_DOWN_URL);

    //Opens upChannel
    this.upChannel(API_UP_URL, tl, af);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号