forked from VcampSoldiers/HearMe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
84 lines (70 loc) · 3 KB
/
test.py
File metadata and controls
84 lines (70 loc) · 3 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
Future<dynamic> speechToText(File file) async {
final bytes = file.readAsBytesSync();
var uri = Uri.parse("https://westus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US");
var request = new http.Request("POST", uri)
..headers['Ocp-Apim-Subscription-Key'] = "d10dd8eff0e145eead43c5a63b808d1e"
..headers['Content-Type'] = "audio/wav"
..bodyBytes = bytes;
var response = await request.send();
print(request);
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
return text;
}
Future<dynamic> addProfile(File file) async {
var uri = Uri.parse("https://westus.api.cognitive.microsoft.com/sts/v1.0/issuetoken/speaker/identification/v2.0/text-independent/profiles");
var request = new http.Request("POST", uri)
..headers['Ocp-Apim-Subscription-Key'] = "d10dd8eff0e145eead43c5a63b808d1e"
..headers['Content-Type'] = "application/json"
..bodyFields['locale'] = 'en-us';
var response = await request.send();
print(request);
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
return profileid;
}
Future<dynamic> enrollProfile(File file, profileid) async {
final bytes = file.readAsBytesSync();
var uri = Uri.parse('https://westus.api.cognitive.microsoft.com/sts/v1.0/issuetoken/speaker/identification/v2.0/text-independent/profiles/{profileid}/enrollments');
var request = new http.Request("POST", uri)
..headers['Ocp-Apim-Subscription-Key'] = "d10dd8eff0e145eead43c5a63b808d1e"
..headers['Content-Type'] = "audio/wav"
..bodyBytes = bytes;
var response = await request.send();
print(request);
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
}
Future<dynamic> identifyProfile(File file) async {
final bytes = file.readAsBytesSync();
var uri = Uri.parse('https://westus.api.cognitive.microsoft.com/sts/v1.0/issuetoken/speaker/identification/v2.0/text-independent/profiles/identifySingleSpeaker?profileIds={profileid}');
var request = new http.Request("POST", uri)
..headers['Ocp-Apim-Subscription-Key'] = "d10dd8eff0e145eead43c5a63b808d1e"
..headers['Content-Type'] = "audio/wav"
..bodyBytes = bytes;
var response = await request.send();
print(request);
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
return profileid, score;
}
Future<dynamic> delete Profile() async {
final bytes = file.readAsBytesSync();
var uri = Uri.parse('https://westus.api.cognitive.microsoft.com/sts/v1.0/issuetoken/speaker/identification/v2.0/text-independent/profiles/INSERT_PROFILE_ID_HERE');
var request = new http.Request("POST", uri)
..headers['Ocp-Apim-Subscription-Key'] = "d10dd8eff0e145eead43c5a63b808d1e"
var response = await request.send();
print(request);
print(response.statusCode);
response.stream.transform(utf8.decoder).listen((value) {
print(value);
});
}