dream

Форк
0
/
test.py 
48 строк · 1.5 Кб
1
import requests
2

3

4
def main():
5
    url = "http://0.0.0.0:8031/asr_check"
6
    input_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
    }
16
    result = requests.post(url, json=input_data)
17
    print(result.json())
18
    assert result.json()[0]["asr_confidence"] == "high"
19

20
    input_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

27
    result = requests.post(url, json=input_data)
28
    assert result.json()[0]["asr_confidence"] == "medium"
29

30
    input_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
    }
36
    result = requests.post(url, json=input_data)
37
    assert result.json()[0]["asr_confidence"] == "very_low"
38

39
    result = requests.post(url, json={"speeches": [[]], "human_utterances": [[]]})
40
    assert result.json()[0]["asr_confidence"] == "undefined"
41

42
    empty_json = {"hypotheses": [{"tokens": []}]}
43
    result = requests.post(url, json={"speeches": [empty_json], "human_utterances": [[]]})
44
    assert result.json()[0]["asr_confidence"] == "undefined"
45

46

47
if __name__ == "__main__":
48
    main()
49

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.