Comments (7)
there is no execution engine for the .js filename extension.
from -prototype-aivtuber.
line 23 character 1 code 800A03EA MICROSOFT COMPILATION ERROR
Syntax error
the error remained even after reinstalling Windows
from -prototype-aivtuber.
You need to create your project in a certain folder like C:\Project\AI_Vtuber and
You must use the command in the folder you want. by using the following command
cd [path address]
e.g. cd C:\Project\AI_Vtuber
then use your command
I think this will solve your problem!
from -prototype-aivtuber.
thank you for helping me solve the previous problem, but now I get this error
from -prototype-aivtuber.
You try replacing your main.js code with this
require('dotenv').config();
var twitch_username = 'TWITCH_USERNAME';
var twitch_token = 'TWITCH_PASSWORD (TWITCH_TOKEN)';
var twitch_channel = [ 'TWITCH_CHANNEL' ];
// FFMPEG
var ffmpeg_path = 'FFMPEG_PATH'; // like this: c:/ffmpeg/bin/ffmpeg.exe
// OPENAI
var openai_organization = 'ORGANIZATION';
var openai_apiKey = 'API_KEY';
// AWS
var aws_region = 'REGION';
var aws_accessKeyId = 'ACCESS_KEY_ID';
var aws_secretAccessKey = 'SECRET_ACCESS_KEY';
const host = 'localhost';
const port = 8000;
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
app.get('/TTS', (req, res) => {
res.sendFile(__dirname + '/tts.html');
});
io.on('connection', (socket) => {
console.log('a user connected');
});
server.listen(port, () => {
console.log(`listening on ${host}:${port}`);
});
const AWS = require('aws-sdk');
const fs = require('fs');
const readline = require('readline');
const tmi = require('tmi.js');
const Speaker = require('speaker');
const wav = require('wav');
const { exec } = require('child_process');
const { Configuration, OpenAIApi } = require('openai');
const configuration = new Configuration({
organization: openai_organization,
apiKey: openai_apiKey,
});
const openai = new OpenAIApi(configuration);
const Polly = new AWS.Polly({
region: aws_region,
accessKeyId: aws_accessKeyId,
secretAccessKey: aws_secretAccessKey
});
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
async function convertMp3ToWav(audioStream) {
try {
await fs.writeFile('path/to/output.mp3', audioStream, (err) => {
if (err) throw err;
});
await fs.unlink('path/to/output.wav', (err) => {
if (err) console.log('No previous file to delete');
});
await new Promise((resolve, reject) => {
exec(`"${ffmpeg_path}" -i "path/to/output.mp3" -acodec pcm_s16le -ac 1 -ar 16000 "path/to/output.wav"`, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} catch (err) {
console.error(err);
}
}
const client = new tmi.Client({
options: { debug: true },
connection: { reconnect: true },
identity: {
username: twitch_username,
password: twitch_token
},
channels: twitch_channel
});
client.connect();
var ready = true;
async function getGptResponse(VARmessage) {
try {
const gptSend = await openai.createCompletion({
model: 'text-curie-001',
prompt: `${VARmessage}`,
temperature: 0.9,
max_tokens: 100,
stop: ["ChatGPT:", "Adrian Twarog:"],
});
return gptSend;
} catch (err) {
console.error(err);
}
}
client.on('message', async (channel, tags, message, self) => {
if(self) return;
if(message){
if(ready == true){
ready = false;
const gptResponse = await getGptResponse(message);
const params = {
OutputFormat: 'mp3',
Text: '<speak><prosody pitch="high">'+message+".................... "+gptResponse.data.choices[0].text+'</prosody></speak>',
TextType: 'ssml',
VoiceId: 'Ivy' // Japanese voice
};
console.log(`${message}`);
console.log(`${gptResponse.data.choices[0].text}`);
Polly.synthesizeSpeech(params, async (err, data) => {
if (err) {
console.log(err.code)
} else if (data) {
if (data.AudioStream instanceof Buffer) {
await convertMp3ToWav(data.AudioStream)
console.log(`File saved.`);
import('music-metadata').then( mm => {
mm.parseFile('path/to/output.mp3', {native: true})
.then(metadata => console.log(metadata.format.duration))
.catch(err => console.error(err.message));
});
try{
const reader = new wav.Reader();
const speaker = new Speaker();
reader.pipe(speaker);
fs.createReadStream('path/to/output.wav').pipe(reader)
io.emit('TTS', { subtitle: `${message}\n${gptResponse.data.choices[0].text}` });
console.log('text !== "exit" : Method')
if (ready == false) {
import('music-metadata').then( mm => {
mm.parseFile('path/to/output.wav', {native: true})
.then(metadata => {
console.log(metadata.format.duration * 1000);
setTimeout(() => {
//mic.stopRecording();
setTimeout(() => {ready = true;io.emit('TTS', { subtitle: "" });}, 2500);
}, metadata.format.duration * 1000);
})
.catch(err => console.error(err.message));
});
}
} catch (err){
console.log(err)
process.exit()
}
}
}
});
}
}
})
function promptUser() {
rl.question('Pronounce by yourself: ', async (text) => {
if(ready == true){
ready = false;
const params = {
OutputFormat: 'mp3',
Text: '<speak><prosody pitch="high">'+text+'</prosody></speak>',
TextType: 'ssml',
VoiceId: 'Ivy' // Japanese voice
};
console.log(`${text}`);
Polly.synthesizeSpeech(params, async (err, data) => {
if (err) {
console.log(err.code)
} else if (data) {
if (data.AudioStream instanceof Buffer) {
// Save the audio stream to a file
await convertMp3ToWav(data.AudioStream)
console.log(`File saved.`);
import('music-metadata').then( mm => {
mm.parseFile('path/to/output.mp3', {native: true})
.then(metadata => console.log(metadata.format.duration))
.catch(err => console.error(err.message));
});
// Play the audio
try{
const reader = new wav.Reader();
const speaker = new Speaker();
reader.pipe(speaker);
fs.createReadStream('path/to/output.wav').pipe(reader)
io.emit('TTS', { subtitle: `${text}` });
console.log('text !== "exit" : Method')
if (text !== 'exit') {
import('music-metadata').then( mm => {
mm.parseFile('path/to/output.wav', {native: true})
.then(metadata => {
console.log(metadata.format.duration * 1000);
setTimeout(() => {
//mic.stopRecording();
setTimeout(() => {promptUser();ready = true;io.emit('TTS', { subtitle: "" });}, 2500);
}, metadata.format.duration * 1000);
})
.catch(err => console.error(err.message));
});
}
} catch (err){
console.log(err)
process.exit()
}
}
}
});
if (text !== 'exit') {
//console.log('cannot get duration from output file');
// setTimeout(() => {
// promptUser();
// }, 5000);
} else {
rl.close();
}
}
});
}
setTimeout(() => { promptUser(); },2500);
I think this will solve your problem!
from -prototype-aivtuber.
from -prototype-aivtuber.
This error message indicates that your device is unable to establish a connection to the Twitch IRC WebSocket server on port 443. There could be several reasons for this issue, including network connectivity problems, firewall restrictions, incorrect server address or port number, or the server may be temporarily down.
To resolve this issue, you can try the following steps:
- Check your internet connection and ensure that it is stable and fast.
- Check if your firewall is blocking the connection to the server. If so, temporarily disable the firewall and try again.
- Verify that the server address and port number are correct.
- If the problem persists, try connecting to the server at a later time, as the server may be temporarily down for maintenance or due to technical issues.
and This issue can occur with token confirmations that do not meet the requirements.
If you still have trouble connecting, it's recommended to reach out to Twitch support for further assistance.
Thanks for the feedback. I will make it even better in the future! 🙂
from -prototype-aivtuber.
Related Issues (20)
- i will let you do the rest
- login aunthentication failed HOT 5
- Is there a code using Azure TTS? HOT 1
- Question HOT 5
- Login Authentication Failed HOT 9
- Error after 'npm install dotenv'. (Pronounce by yourself: HOT 1
- I dont even know HOT 2
- I have a error :( HOT 1
- TTS issues HOT 1
- Error when reading from chatgpt
- how do I install npm HOT 3
- I tried my best but...
- npm install error
- Undefiend data
- Don't make the AI respond to bots
- Error after 'npm install dotenv'. HOT 16
- Error after 'node main.js'. HOT 5
- SUGGESTION: allow her to be used as a desktop asssitant HOT 1
- commit HOT 1
- Is there code for youtube? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from -prototype-aivtuber.