Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/litomore/mac-say

The macOS built-in `say` interface for JavaScript
https://github.com/litomore/mac-say

macos say speech spoken-content text-to-speech

Last synced: about 2 months ago
JSON representation

The macOS built-in `say` interface for JavaScript

Awesome Lists containing this project

README

        

# mac-say

The macOS built-in `say` CLI for JavaScript

## Install

```shell
npm i mac-say
```

## Usage

```javascript
import { say } from "mac-say";

await say("Hello, world!");
await say("Hello! My name is Cellos.", { voice: "Cellos" });
```

## API

### say(text, options?)

#### text

Type: `string`

The content to be converted to audible speech.

#### options

Type: `SayOptions`

Optional. All available options are listed below:

```typescript
type SayOptions = {
voice?: string;
rate?: number;
audioDevice?: string;
quality?: number;
inputFile?: string;
outputFile?: string;
networkSend?: string;
channels?: number;
skipRunningCheck?: boolean;
};
```

Please refer to [`man say`](https://www.unix.com/man-page/osx/1/say/) for usage of all options.

### getAudioDevices()

To obtain a list of audio output devices.

Returns a [`Promise`][types].

### getDataFormats(fileFormat)

To obtain a list of audio data formats for a file format specified explicitly or by file name.

Returns a [`Promise`][types].

#### fileForamt

Type: `string`

Formats other than linear PCM are specified by giving their format identifiers (aac, alac).

### getFileFormats()

To obtain a list of writable file formats.

Returns a [`Promise`][types].

### getVoices()

To obtain a list of voices installed in the system.

Returns a [`Promise`][types].

### checkIfSayIsRunning()

To obtain the information of the `say` process.

Returns a [`Promise`](https://github.com/sindresorhus/ps-list/blob/46f7d16920ed12c2866ddacc5044df7f8f87b179/index.d.ts#L13-L38).

### killRunningSay()

To kill the say process if it's running.

## Related

- [Say - Spoken Content](https://raycast.com/litomore/say) - macOS built-in Spoken Content interface

## License

MIT

[types]: https://github.com/LitoMore/mac-say/blob/main/source/types.ts