app.js
3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//app.js
App({
onLaunch () {
},
globalData: {
getTypeList(){
return [
{
desc: '男声一',
createUrl(text){
return `https://fanyi.sogou.com/reventondc/synthesis?text=${text}&speed=1&lang=zh-CHS&from=translateweb&speaker=1`
}
},
{
desc: '男声二',
createUrl(text){
return `https://fanyi.sogou.com/reventondc/synthesis?text=${text}&speed=1&lang=zh-CHS&from=translateweb&speaker=4`
}
},
{
desc: '女声一',
createUrl(text){
return `https://fanyi.sogou.com/reventondc/synthesis?text=${text}&speed=1&lang=zh-CHS&from=translateweb&speaker=2`
}
},
{
desc: '女声二',
createUrl(text){
return `https://fanyi.sogou.com/reventondc/synthesis?text=${text}&speed=1&lang=zh-CHS&from=translateweb&speaker=3`
}
},
{
desc: '女声三',
createUrl(text){
return `https://fanyi.sogou.com/reventondc/synthesis?text=${text}&speed=1&lang=zh-CHS&from=translateweb&speaker=5`
}
},
{
desc: '女声四',
createUrl(text){
return `https://fanyi.sogou.com/reventondc/synthesis?text=${text}&speed=1&lang=zh-CHS&from=translateweb&speaker=6`
}
},
{
desc: '女声五',
createUrl(text){
return `https://tts.youdao.com/fanyivoice?word=${text}&le=zh&keyfrom=speaker-target`
}
}
];
},
getSelectedTypeIndex(){
const storageKey = 'audioTypeselectedIndex';
return wx.getStorageSync(storageKey);
},
setSelectedTypeIndex(index){
const storageKey = 'audioTypeselectedIndex';
wx.setStorageSync(storageKey, index);
return index;
},
getAudioList(){
const storageKey = 'audioList';
return wx.getStorageSync(storageKey) || [];
},
/**
* @param {(add|delete)} action - 增或删
* @param {object|number} [param] - 增加时是 audio 描述,删除时是唯一特征 path 值
*/
setAudioList(action, param){
const storageKey = 'audioList';
const list = this.getAudioList() || [];
if(action === 'add' && param.constructor === Object){
list.push(param);
wx.setStorageSync(storageKey, list);
}
if(action === 'delete' && String(param)){
const index = list.findIndex(v => v.path === param);
if(index > -1){
list.splice(index, 1);
wx.setStorageSync(storageKey, list);
}
}
return list;
}
}
});