whisper.rs 2.04 KB
Newer Older
1
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
3
4
5
6
7
// SPDX-License-Identifier: Apache-2.0
//
// Based on https://github.com/64bit/async-openai/ by Himanshu Neema
// Original Copyright (c) 2022 Himanshu Neema
// Licensed under MIT License (see ATTRIBUTIONS-Rust.md)
//
8
// Modifications Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES.
9
10
// Licensed under Apache 2.0

11
12
use dynamo_protocols::types::CreateTranslationRequestArgs;
use dynamo_protocols::{Client, types::CreateTranscriptionRequestArgs};
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
use tokio_test::assert_err;

#[tokio::test]
async fn transcribe_test() {
    let client = Client::new();

    let request = CreateTranscriptionRequestArgs::default().build().unwrap();

    let response = client.audio().transcribe(request).await;

    assert_err!(response); // FileReadError("cannot extract file name from ")
}

#[tokio::test]
async fn transcribe_sendable_test() {
    let client = Client::new();

    // https://github.com/64bit/async-openai/issues/140
    let transcribe = tokio::spawn(async move {
        let request = CreateTranscriptionRequestArgs::default().build().unwrap();

        client.audio().transcribe(request).await
    });

    let response = transcribe.await.unwrap();

    assert_err!(response); // FileReadError("cannot extract file name from ")
}

#[tokio::test]
async fn translate_test() {
    let client = Client::new();

    let request = CreateTranslationRequestArgs::default().build().unwrap();

    let response = client.audio().translate(request).await;

    assert_err!(response); // FileReadError("cannot extract file name from ")
}

#[tokio::test]
async fn translate_sendable_test() {
    let client = Client::new();

    // https://github.com/64bit/async-openai/issues/140
    let translate = tokio::spawn(async move {
        let request = CreateTranslationRequestArgs::default().build().unwrap();

        client.audio().translate(request).await
    });

    let response = translate.await.unwrap();

    assert_err!(response); // FileReadError("cannot extract file name from ")
}