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
use anyhow::Result;

use crate::Client;

pub struct Captions {
    pub client: Client,
}

impl Captions {
    #[doc(hidden)]
    pub fn new(client: Client) -> Self {
        Captions { client }
    }

    /**
     * Get Captions.
     *
     * This function performs a `GET` to the `/jobs/{id}/captions` endpoint.
     *
     * Returns the caption output for a transcription job. We currently support SubRip (SRT) and Web Video Text Tracks (VTT) output.
     * Caption output format can be specified in the `Accept` header. Returns SRT by default.
     * ***
     * Note: For streaming jobs, transient failure of our storage during a live session may prevent the final hypothesis elements from saving properly, resulting in an incomplete caption file. This is rare, but not impossible.
     *
     *
     * **Parameters:**
     *
     * * `accept: crate::types::Accept` -- MIME type specifying the caption output format.
     * * `speaker_channel: i64` -- Identifies which channel of the job output to caption. Default is `null` which works only for jobs with no `speaker_channels_count` provided during job submission.
     */
    pub async fn get(
        &self,
        id: &str,
        accept: crate::types::Accept,
        speaker_channel: i64,
    ) -> Result<String> {
        let mut query_args: Vec<(String, String)> = Default::default();
        if speaker_channel > 0 {
            query_args.push(("speaker_channel".to_string(), speaker_channel.to_string()));
        }
        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
        let url = format!(
            "/jobs/{}/captions?{}",
            crate::progenitor_support::encode_path(&id.to_string()),
            query_
        );

        self.client
            .request_with_accept_mime(reqwest::Method::GET, &url, &accept.to_string())
            .await
    }
}