Skip to content

Commit 4311213

Browse files
committed
Test openai default tts
1 parent 3c3b245 commit 4311213

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
<h3 align="center">Use AI in the terminal</h3>
44

5-
## Philosophy
6-
7-
The philosophy of this project is mainly to not handle state.
8-
Like curl or ffmpeg, this should make it easier to use in scripts and to share examples online.
9-
Settings are done via command line arguments and environment variables.
10-
115
## Examples
126

13-
### Text to Speech and Bash
7+
### Text to Speech in Bash
148

159
We can read a file out loud from the command line.
1610
For example, with the OpenAI API:
@@ -42,7 +36,7 @@ After adding `spk.sh` to your PATH, you can use it like this:
4236
$ cat myfile.txt | spk
4337
```
4438

45-
### Other Text to Speech
39+
### Other Text to Speech Commands
4640

4741
```sh
4842
$ DEEPINFRA_KEY="$(cat /path/to/key)"; cat myfile.txt | ata tts | vlc -
@@ -52,3 +46,8 @@ $ DEEPINFRA_KEY="$(cat /path/to/key)"; cat myfile.txt | ata tts | vlc -
5246
$ DEEPINFRA_KEY="$(cat /path/to/key)"; cat myfile.txt | ata tts --output myfile.mp3
5347
```
5448

49+
## Philosophy
50+
51+
The philosophy of this project is mainly to not handle state.
52+
Like curl or ffmpeg, this should make it easier to use in scripts and to share examples online.
53+
Settings are done via command line arguments and environment variables.

tests/cli.rs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,32 @@ fn load_key(provider: &Provider) -> String {
5050
}
5151

5252
#[test]
53-
fn tts_no_args_output() -> Result<(), Box<dyn std::error::Error>> {
53+
fn tts_no_args() -> Result<(), Box<dyn std::error::Error>> {
5454
let dir = tempfile::tempdir().unwrap();
5555
let mut cmd = ata();
5656
let key = load_key(&Provider::DeepInfra);
57+
let cmd = cmd
58+
.arg("tts")
59+
.env("DEEPINFRA_KEY", key)
60+
.write_stdin("Hello world")
61+
.current_dir(&dir);
62+
let output = cmd.assert().success().get_output().stdout.clone();
63+
64+
assert!(output.len() > 0);
65+
66+
Ok(())
67+
}
68+
69+
fn tts_default_settings_helper(provider: &Provider) -> Result<(), Box<dyn std::error::Error>> {
70+
let dir = tempfile::tempdir().unwrap();
71+
let mut cmd = ata();
72+
let key = load_key(provider);
73+
let name = provider.key_name();
5774
cmd.arg("tts")
5875
.arg("--output")
5976
.arg("output.mp3")
60-
.env("DEEPINFRA_KEY", key)
61-
.write_stdin("Hello world")
77+
.env(name, key)
78+
.write_stdin("Hi")
6279
.current_dir(&dir)
6380
.assert()
6481
.success();
@@ -70,18 +87,11 @@ fn tts_no_args_output() -> Result<(), Box<dyn std::error::Error>> {
7087
}
7188

7289
#[test]
73-
fn tts_no_args() -> Result<(), Box<dyn std::error::Error>> {
74-
let dir = tempfile::tempdir().unwrap();
75-
let mut cmd = ata();
76-
let key = load_key(&Provider::DeepInfra);
77-
let cmd = cmd
78-
.arg("tts")
79-
.env("DEEPINFRA_KEY", key)
80-
.write_stdin("Hello world")
81-
.current_dir(&dir);
82-
let output = cmd.assert().success().get_output().stdout.clone();
83-
84-
assert!(output.len() > 0);
90+
fn tts_no_args_deepinfra() -> Result<(), Box<dyn std::error::Error>> {
91+
tts_default_settings_helper(&Provider::DeepInfra)
92+
}
8593

86-
Ok(())
94+
#[test]
95+
fn tts_no_args_openai() -> Result<(), Box<dyn std::error::Error>> {
96+
tts_default_settings_helper(&Provider::OpenAI)
8797
}

0 commit comments

Comments
 (0)