dream
48 строк · 1.5 Кб
1import requests
2
3
4def main():
5url = "http://0.0.0.0:8031/asr_check"
6input_data = {
7"speeches": [
8{
9"hypotheses": [
10{"tokens": [{"confidence": 0.95, "value": "let's"}, {"confidence": 0.968, "value": "chat"}]}
11]
12}
13],
14"human_utterances": [[{"text": "let's chat"}]],
15}
16result = requests.post(url, json=input_data)
17print(result.json())
18assert result.json()[0]["asr_confidence"] == "high"
19
20input_data = {
21"speeches": [
22{"hypotheses": [{"tokens": [{"confidence": 0.6, "value": "let's"}, {"confidence": 0.6, "value": "chat"}]}]}
23],
24"human_utterances": [[{"text": "let's chat"}]],
25}
26
27result = requests.post(url, json=input_data)
28assert result.json()[0]["asr_confidence"] == "medium"
29
30input_data = {
31"speeches": [
32{"hypotheses": [{"tokens": [{"confidence": 0.1, "value": "let's"}, {"confidence": 0.1, "value": "chat"}]}]}
33],
34"human_utterances": [[{"text": "let's chat"}]],
35}
36result = requests.post(url, json=input_data)
37assert result.json()[0]["asr_confidence"] == "very_low"
38
39result = requests.post(url, json={"speeches": [[]], "human_utterances": [[]]})
40assert result.json()[0]["asr_confidence"] == "undefined"
41
42empty_json = {"hypotheses": [{"tokens": []}]}
43result = requests.post(url, json={"speeches": [empty_json], "human_utterances": [[]]})
44assert result.json()[0]["asr_confidence"] == "undefined"
45
46
47if __name__ == "__main__":
48main()
49