NIMSDK-AOS  10.10.13
V2NIMVoiceToTextParams.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.v2.message.params;
2 
3 import android.text.TextUtils;
4 
6 
7 public class V2NIMVoiceToTextParams {
8 
9  // 本地语音文件路径
10  // voicePath/ voiceUrl必须二选一
11  private final String voicePath;
12 
13  // 语音url,如果没有内部自动上传
14  // voicePath/ voiceUrl必须二选
15  private final String voiceUrl;
16 
17  // 音频类型:语音类型,aac, wav, mp3, amr等
18  private final String mimeType;
19 
20  // 采样率,8000, 16000, 44100, 48000等
21  private final String sampleRate;
22 
23  // 语音时长, 单位毫秒
24  private final long duration;
25 
26  //文件存储场景
27  //自定义场景使用之前, 需要先调用V2NIMStorageService.addCustomStorageScene新增自定义场景值
28  //默认使用:V2NIMStorageSceneConfig.DEFAULT_IM
29  private final String sceneName;
30 
31  private V2NIMVoiceToTextParams() {
32  this("", "", null, null, 0, "");
33  }
34 
35  private V2NIMVoiceToTextParams(String voicePath, String voiceUrl, String mimeType, String sampleRate, long duration, String sceneName) {
36  this.voicePath = voicePath;
37  this.voiceUrl = voiceUrl;
38  this.mimeType = mimeType;
39  this.sampleRate = sampleRate;
40  this.duration = duration;
41  this.sceneName = sceneName;
42  }
43 
44  public String getVoicePath() {
45  return voicePath;
46  }
47 
48  public String getVoiceUrl() {
49  return voiceUrl;
50  }
51 
52  public String getMimeType() {
53  return mimeType;
54  }
55 
56  public String getSampleRate() {
57  return sampleRate;
58  }
59 
60  public long getDuration() {
61  return duration;
62  }
63 
64  public String getSceneName() {
65  if (TextUtils.isEmpty(sceneName)) {
67  } else {
68  return sceneName;
69  }
70  }
71 
72  @Override
73  public String toString() {
74  return "V2NIMVoiceToTextParams{" +
75  "voicePath='" + voicePath + '\'' +
76  ", voiceUrl='" + voiceUrl + '\'' +
77  ", mimeType='" + mimeType + '\'' +
78  ", sampleRate='" + sampleRate + '\'' +
79  ", duration=" + duration +
80  ", sceneName='" + sceneName + '\'' +
81  '}';
82  }
83 
84 
85  public static final class V2NIMVoiceToTextParamsBuilder {
86  private String voicePath;
87  private String voiceUrl;
88  private String mimeType;
89  private String sampleRate;
90  private final long duration;
91  private String sceneName;
92 
93  private V2NIMVoiceToTextParamsBuilder(long duration) {
94  this.duration = duration;
95  }
96 
97  public static V2NIMVoiceToTextParamsBuilder builder(final long duration) {
98  return new V2NIMVoiceToTextParamsBuilder(duration);
99  }
100 
101  public V2NIMVoiceToTextParamsBuilder withVoicePath(String voicePath) {
102  this.voicePath = voicePath;
103  return this;
104  }
105 
106  public V2NIMVoiceToTextParamsBuilder withVoiceUrl(String voiceUrl) {
107  this.voiceUrl = voiceUrl;
108  return this;
109  }
110 
111  public V2NIMVoiceToTextParamsBuilder withMimeType(String mimeType) {
112  this.mimeType = mimeType;
113  return this;
114  }
115 
116  public V2NIMVoiceToTextParamsBuilder withSampleRate(String sampleRate) {
117  this.sampleRate = sampleRate;
118  return this;
119  }
120 
121  public V2NIMVoiceToTextParamsBuilder withSceneName(String sceneName) {
122  this.sceneName = sceneName;
123  return this;
124  }
125 
126  public V2NIMVoiceToTextParams build() {
127  return new V2NIMVoiceToTextParams(voicePath, voiceUrl, mimeType, sampleRate, duration, sceneName);
128  }
129  }
130 }
static final V2NIMStorageScene DEFAULT_IM
默认文件类型等场景 默认不过期