Skip to content

Commit 79a4ab0

Browse files
committed
Test no --output tts
1 parent 8cfa41a commit 79a4ab0

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Settings are done via command line arguments and environment variables.
1010

1111
## Examples
1212

13-
### Text to Speech
13+
### Text to Speech and Bash
1414

15-
We can create a script to read a file out loud.
15+
We can read a file out loud from the command line.
1616
For example, with the OpenAI API:
1717

1818
```sh
@@ -23,7 +23,7 @@ Here, we set the key, print the file `myfile.txt` to stdout, pipe it to `ata` to
2323
The `--intf dummy` is optional; it just prevents `vlc` from opening a GUI.
2424

2525
One way to make this easier to use is to create a Bash script that sets the environment variable and runs the command.
26-
For example, create a file called `spk.sh` (read: speak) with the following content:
26+
For example, create a file called `spk.sh` (abbreviation for "speak") with the following content:
2727

2828
```bash
2929
#!/usr/bin/env bash
@@ -41,3 +41,14 @@ After adding `spk.sh` to your PATH, you can use it like this:
4141
```sh
4242
$ cat myfile.txt | spk
4343
```
44+
45+
### Other Text to Speech
46+
47+
```sh
48+
$ DEEPINFRA_KEY="$(cat /path/to/key)"; cat myfile.txt | ata --tts | vlc -
49+
```
50+
51+
```sh
52+
$ DEEPINFRA_KEY="$(cat /path/to/key)"; cat myfile.txt | ata --tts --output myfile.mp3
53+
```
54+

tests/cli.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn load_key(provider: &Provider) -> String {
5050
}
5151

5252
#[test]
53-
fn tts_no_args() -> Result<(), Box<dyn std::error::Error>> {
53+
fn tts_no_args_output() -> Result<(), Box<dyn std::error::Error>> {
5454
let dir = tempfile::tempdir().unwrap();
5555
let mut cmd = ata();
5656
let key = load_key(&Provider::DeepInfra);
@@ -68,3 +68,23 @@ fn tts_no_args() -> Result<(), Box<dyn std::error::Error>> {
6868

6969
Ok(())
7070
}
71+
72+
#[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.arg("--tts")
78+
.env("DEEPINFRA_KEY", key)
79+
.write_stdin("Hello world")
80+
.current_dir(&dir);
81+
let output = cmd.assert()
82+
.success()
83+
.get_output()
84+
.stdout
85+
.clone();
86+
87+
assert!(output.len() > 0);
88+
89+
Ok(())
90+
}

0 commit comments

Comments
 (0)