> ## Content Index
> Fetch the complete content index at: https://www.bramadams.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# A Chat with GPT: Poem Recorder
- URL: https://www.bramadams.dev/202303282129/
- Published: 2023-03-29T01:39:26.000Z
- Updated: 2023-03-29T01:39:26.000Z
- Description: Could the great writers of the past have preferred to speak into a microphone or film their works instead of writing them down?
- Author: Bram Adams
- Tags: chatgpt

![https://bram-adams.ghost.io/content/images/2023/03/Attachments/A-Chat-with-GPT---Poem-Recorder-1.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-1.png)

Attachments/A Chat with GPT - Poem Recorder 1.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-2.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-2.png)

A Chat with GPT - Poem Recorder 2.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-3.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-3.png)

A Chat with GPT - Poem Recorder 3.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-4.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-4.png)

A Chat with GPT - Poem Recorder 4.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-5.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-5.png)

A Chat with GPT - Poem Recorder 5.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-6.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-6.png)

A Chat with GPT - Poem Recorder 6.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-7.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-7.png)

A Chat with GPT - Poem Recorder 7.png

**bramadams.dev is a reader-supported [published Zettelkasten](https://www.bramadams.dev/about/). [Both free and paid subscriptions are available](#/portal). If you want to support my work, the best way is by taking out a paid subscription.**

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-8.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-8.png)

A Chat with GPT - Poem Recorder 8.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-9.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-9.png)

A Chat with GPT - Poem Recorder 9.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-10.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-10.png)

A Chat with GPT - Poem Recorder 10.png

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-11.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-11.png)

A Chat with GPT - Poem Recorder 11.png

## poem\_recorder.js

```js
const mic = require('mic');
const fs = require('fs');

const micInstance = mic({
    rate: '16000',
    channels: '1',
    debug: true,
});

const micInputStream = micInstance.getAudioStream();
const outputFileStream = fs.WriteStream('output.raw');

micInputStream.pipe(outputFileStream);

console.log('Recording started. Press Ctrl+C to stop.');

micInstance.start();

// Excerpt from Homer's "The Iliad"
const transcript = [
    'Sing, O goddess, the anger of Achilles son of Peleus,',
    'that brought countless ills upon the Achaeans.',
    'Many a brave soul did it send hurrying down to Hades,',
    'and many a hero did it yield a prey to dogs and vultures,',
    'for so were the counsels of Jove fulfilled from the day on',
    'which the son of Atreus, king of men, and great Achilles,',
    'first fell out with one another.'
];

let currentLine = 0;
const interval = setInterval(() => {
    if (currentLine < transcript.length) {
        console.log(transcript[currentLine]);
        currentLine++;
    } else {
        clearInterval(interval);
    }
}, 5000); // Scroll every 5 seconds

// micInputStream.on('data', function(data) {
//     console.log("Recieved Input Stream: " + data.length);
// });
 
micInputStream.on('error', function(err) {
    cosole.log("Error in Input Stream: " + err);
});
 
micInputStream.on('startComplete', function() {
    console.log("Got SIGNAL startComplete");
    setTimeout(function() {
            micInstance.pause();
    }, 5000);
});
    
micInputStream.on('stopComplete', function() {
    console.log("Got SIGNAL stopComplete");
});
    
micInputStream.on('pauseComplete', function() {
    console.log("Got SIGNAL pauseComplete");
    setTimeout(function() {
        micInstance.resume();
    }, 5000);
});
 
micInputStream.on('resumeComplete', function() {
    console.log("Got SIGNAL resumeComplete");
    setTimeout(function() {
        micInstance.stop();
    }, 5000);
});
 
micInputStream.on('silence', function() {
    console.log("Got SIGNAL silence");
});
 
micInputStream.on('processExitComplete', function() {
    console.log("Got SIGNAL processExitComplete");
});

process.on('SIGINT', () => {
    micInstance.stop();
    clearInterval(interval);
    console.log('Recording stopped.');
    process.exit(0);
});

// to play the audio file, run the following command (macOS):
// $ play -b 16 -e signed -c 1 -r 16000 output.raw

```

It works!

![https://bram-adams.ghost.io/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-result.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/03/A-Chat-with-GPT---Poem-Recorder-result.png)

A Chat with GPT - Poem Recorder result.png