View Javadoc
1   package com.zone.weixin4j.message;
2   
3   import com.zone.weixin4j.request.WeixinMessage;
4   import com.zone.weixin4j.type.MessageType;
5   
6   import javax.xml.bind.annotation.XmlElement;
7   
8   /**
9    * 语音消息
10   * <p>
11   * 开通语音识别功能,用户每次发送语音给公众号时,微信会在推送的语音消息XML数据包中,赋值到Recongnition字段.
12   * </p>
13   * 
14   * @className VoiceMessage
15   * @author jinyu(foxinmy@gmail.com)
16   * @date 2014年4月6日
17   * @since JDK 1.6
18   * @see <a
19   *      href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140453&token=&lang=zh_CN">订阅号、服务号的语音消息</a>
20   * @see <a
21   *      href="http://qydev.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E6%99%AE%E9%80%9A%E6%B6%88%E6%81%AF#voice.E6.B6.88.E6.81.AF">企业号的语音消息</a>
22   */
23  public class VoiceMessage extends WeixinMessage {
24  
25  	private static final long serialVersionUID = -7988380977182214003L;
26  
27  	public VoiceMessage() {
28  		super(MessageType.voice.name());
29  	}
30  
31  	/**
32  	 * 语音消息媒体id,可以调用多媒体文件下载接口拉取数据。
33  	 */
34  	@XmlElement(name = "MediaId")
35  	private String mediaId;
36  	/**
37  	 * 语音格式,如amr,speex等
38  	 */
39  	@XmlElement(name = "Format")
40  	private String format;
41  	/**
42  	 * 语音识别结果,UTF8编码
43  	 */
44  	@XmlElement(name = "Recognition")
45  	private String recognition;
46  
47  	public String getRecognition() {
48  		return recognition;
49  	}
50  
51  	public String getMediaId() {
52  		return mediaId;
53  	}
54  
55  	public String getFormat() {
56  		return format;
57  	}
58  
59  	@Override
60  	public String toString() {
61  		return "VoiceMessage [mediaId=" + mediaId + ", format=" + format
62  				+ ", recognition=" + recognition + ", " + super.toString()
63  				+ "]";
64  	}
65  }