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
88
89
90
91
92
93
94
95
96
97
98
99
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { intentBaseService } from '../../../../core/services/intentBase.service';
import { Recorder } from '../../../../shared/utils/recorder';
import { Util } from '../../../../shared/utils/utils';
@Component({
selector: 'app-smart-cloud-leased-modal',
templateUrl: './smart-cloud-leased-modal.component.html',
styleUrls: ['./smart-cloud-leased-modal.component.less']
})
export class SmartCloudLeasedModalComponent implements OnInit {
constructor(
private Util: Util,
private Recorder: Recorder,
private myhttp: intentBaseService,
private msg: NzMessageService
) {}
@Input() samrtCloudLeasedLineShowFlag: boolean;
@Output() resolveEmitter = new EventEmitter();
communicationMessage: String = "";
validateRulesShow: any[] = [];
rulesText: any[] = [];
radioValue: String = 'text';
isPlay: boolean = false;
clickRepeat: boolean = false;
isDisable: boolean = true;
ngOnInit() {
this.validateRulesShow = [];
this.rulesText = [];
this.communicationMessage = '';
}
ngOnChange() {}
handleCancel(flag, data=null): void {
this.samrtCloudLeasedLineShowFlag = false;
this.communicationMessage = "";
this.resolveEmitter.emit({ cancel: flag, data: data});
}
handleOk(): void {
if (this.radioValue === 'text') {
this.submitFormMessage();
return;
}
}
submitFormAudio() {
this.handleCancel(false);
}
submitFormMessage(): void {
let params = {
"title": "predict",
"modelType": 'ccvpn',
"text": this.communicationMessage
};
this.myhttp.intentInstancePredict(params).subscribe(
(response) => {
const { code, message, data } = response;
if (code !== 200) {
this.msg.error(message);
return;
}
let orderForm = {
...data,
intentContent: this.communicationMessage
};
this.handleCancel(false, orderForm);
},
(err) => {
console.log(err);
}
)
}
startAudio(): void {
this.isPlay = true;
this.isDisable = true;
this.Recorder.beforeStartRecord();
}
stopAudio(): void {
this.isPlay = false;
this.isDisable = false;
this.Recorder.stopRecord();
}
playAudio(): void {
let audio = document.querySelector('audio');
audio["src"] = this.Recorder.playRecord();
}
}
|