Commit 225ebf93 authored by 李帅's avatar 李帅

+1

parent c5834d39
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-15 18:22:18 * @Date: 2022-05-15 18:22:18
* @LastEditTime: 2022-05-31 21:56:35 * @LastEditTime: 2022-06-08 23:00:12
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts
...@@ -236,7 +236,34 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -236,7 +236,34 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.log(`录音的音频URL是${JSON.parse(res).audioUrl}`); this.log(`录音的音频URL是${JSON.parse(res).audioUrl}`);
if (idx !== -1) { if (idx !== -1) {
this.content.children[idx].getComponent(Item).recorded(); let it = this.content.children[idx].getComponent(Item);
it.recorded();
let arr = JSON.parse(res).result.sentences[0].details;
let arrOne = [];
for (let index = 0; index < arr.length; index++) {
let e = arr[index];
arrOne.push({ key: e.word, value: 1 });
let result = {};
arrOne.forEach((item) => {
if (result[item.key]) {
result[item.key] += item.value;
} else {
result[item.key] = item.value;
}
});
for (let k in result) {
if (k === e.word) {
if (e.overall < 40) {
it.setLow(e.word, result[k]);
}
}
}
}
} }
this.resetRecord(); this.resetRecord();
......
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-21 21:59:51 * @Date: 2022-05-21 21:59:51
* @LastEditTime: 2022-05-31 21:15:17 * @LastEditTime: 2022-06-08 22:57:27
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts
...@@ -31,6 +31,9 @@ export default class Item extends cc.Component { ...@@ -31,6 +31,9 @@ export default class Item extends cc.Component {
@property(cc.Node) @property(cc.Node)
myrecord_play: cc.Node = null; myrecord_play: cc.Node = null;
@property(cc.Node)
low: cc.Node = null;
// 录制中 // 录制中
_recording = false; _recording = false;
// 已录音 // 已录音
...@@ -144,6 +147,7 @@ export default class Item extends cc.Component { ...@@ -144,6 +147,7 @@ export default class Item extends cc.Component {
this.tip.active = true; this.tip.active = true;
// this.label.node.color = cc.color(255, 96, 0); // this.label.node.color = cc.color(255, 96, 0);
this.label.node.color = cc.color(108, 185, 0); this.label.node.color = cc.color(108, 185, 0);
this.hideLow();
} }
/** /**
...@@ -152,5 +156,37 @@ export default class Item extends cc.Component { ...@@ -152,5 +156,37 @@ export default class Item extends cc.Component {
stop() { stop() {
this.tip.active = false; this.tip.active = false;
this.label.node.color = cc.color(44, 77, 140); this.label.node.color = cc.color(44, 77, 140);
this.showLow();
}
hideLow() {
this.label.node.children.forEach((e) => {
e.active = false;
});
}
showLow() {
this.label.node.children.forEach((e) => {
e.active = true;
});
}
clearLow() {
this.label.node.removeAllChildren();
}
setLow(str: string, index: number = 1) {
let ps = this.label.getTargetStringPos(str);
if (index > ps.length) {
return;
}
let p = ps[index - 1];
let low = cc.instantiate(this.low);
low.parent = this.label.node;
low.active = true;
low.width = p.z;
low.getComponentInChildren(cc.Label).string = str;
low.setPosition(p.y, (p.x - 1) * 48);
} }
} }
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-15 18:22:18 * @Date: 2022-05-15 18:22:18
* @LastEditTime: 2022-05-22 00:13:54 * @LastEditTime: 2022-06-08 21:16:09
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\defaultData.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\script\defaultData.ts
...@@ -19,7 +19,7 @@ export const defaultData = { ...@@ -19,7 +19,7 @@ export const defaultData = {
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3', audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
}, },
{ {
text: 'Good morning', text: 'what can i do for you',
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3', audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
}, },
{ {
...@@ -34,21 +34,5 @@ export const defaultData = { ...@@ -34,21 +34,5 @@ export const defaultData = {
text: 'Hello, how dare you, Hello, how dare you', text: 'Hello, how dare you, Hello, how dare you',
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3', audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
}, },
{
text: 'Hello, how dare you, Hello, how dare you',
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
},
{
text: 'Hello, how dare you, Hello, how dare you',
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
},
{
text: 'Hello, how dare you, Hello, how dare you',
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
},
{
text: 'Hello, how dare you, Hello, how dare you',
audio: 'http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3',
},
], ],
}; };
/* /*
* @Author: ls * @Author: ls
* @Date: 2022-05-21 18:06:20 * @Date: 2022-05-21 18:06:20
* @LastEditTime: 2022-05-31 22:45:56 * @LastEditTime: 2022-06-08 21:39:12
* @LastEditors: ls * @LastEditors: ls
* @Description: * @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\simpleLabel.ts * @FilePath: \ls_gramophone\assets\ls_gramophone\script\simpleLabel.ts
...@@ -142,7 +142,7 @@ export default class simpleLabel extends cc.Component { ...@@ -142,7 +142,7 @@ export default class simpleLabel extends cc.Component {
getTargetStringPos(str: string) { getTargetStringPos(str: string) {
let poss = []; let poss = [];
let rows = 0; let rows = this._rows;
let lastString = ''; let lastString = '';
if (this._sourceArray && this._sourceArray.length) { if (this._sourceArray && this._sourceArray.length) {
for (let index = 0; index < this._sourceArray.length; index++) { for (let index = 0; index < this._sourceArray.length; index++) {
...@@ -162,22 +162,20 @@ export default class simpleLabel extends cc.Component { ...@@ -162,22 +162,20 @@ export default class simpleLabel extends cc.Component {
// 增加行数 // 增加行数
lastString = element; lastString = element;
tempString = ''; tempString = '';
rows++; rows--;
} }
let temp = element; let temp = element;
if (element.indexOf(',') !== -1) { if (element.indexOf(',') !== -1 || element.indexOf('.') !== -1 || element.indexOf('!') !== -1 || element.indexOf('?') !== -1) {
temp.substring(element.indexOf(','), 1); temp = temp.substring(0, temp.length - 1);
} else if (element.indexOf('.') !== -1) {
temp.substring(element.indexOf('.'), 1);
} else if (element.indexOf('!') !== -1) {
temp.substring(element.indexOf('!'), 1);
} else if (element.indexOf('?') !== -1) {
temp.substring(element.indexOf('?'), 1);
} }
if (temp === str) { if (temp === str) {
poss.push(rows, this.getLetterWidth(this.label, tempString), this.getLetterWidth(this.label, str)); let x = this.getLetterWidth(this.label, tempString);
if (x !== 0) {
x += this.getLetterWidth(this.label, ' ');
}
poss.push(cc.v3(rows, x, this.getLetterWidth(this.label, str)));
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment