fix strange error where env variables are not read but somehow cashed. fixed by renaming the .env variable.

addind auto-detect of tts language
This commit is contained in:
Dobromir Popov 2024-06-10 12:45:23 +03:00
parent aac600ebaf
commit 11de0b27d2
12 changed files with 91 additions and 36 deletions

2
.env
View File

@ -4,7 +4,7 @@ TTS_BACKEND_URL=https://api.tts.d-popov.com/
#TTS_BACKEND_URL=http://localhost:9001/asr #gpu 9002-cpu
TTS_BACKEND_URL2=http://localhost:9002/asr
TTS_BACKEND_URL3=http://192.168.0.10:9008/asr #gpu
TTS_BACKEND_URL4=http://192.168.0.10:9009/asr #cpu 9008-gpu
#! TTS_BACKEND_URL4=http://192.168.0.10:9009/asr #cpu 9008-gpu
WS_URL=ws://localhost:8081
SERVER_PORT_WS=8081
SERVER_PORT_HTTP=3005

View File

@ -1,6 +1,6 @@
TTS_BACKEND_URL=http://192.168.0.10:9008/asr
WS_URL=ws://192.168.0.10:9008:8081
SERVER_PORT_WS=8081
SERVER_PORT_HTTP=8080
# TTS_BACKEND_URL=http://192.168.0.10:9008/asr
# WS_URL=ws://192.168.0.10:9008
# SERVER_PORT_WS=8081
# SERVER_PORT_HTTP=8080

6
.env.development Normal file
View File

@ -0,0 +1,6 @@
ENV_NAME=development
TTS_API_URL=https://api.tts.d-popov.com/asr
WS_URL=ws://localhost:8081
SERVER_PORT_WS=8081
SERVER_PORT_HTTP=8080

View File

@ -2,7 +2,7 @@
TTS_BACKEND_URL=http://localhost:9001/asr #gpu 9002-cpu
TTS_BACKEND_URL2=http://localhost:9002/asr
TTS_BACKEND_URL3=http://192.168.0.10:9008/asr #gpu
TTS_BACKEND_URL4=http://192.168.0.10:9009/asr #cpu 9008-gpu
#! TTS_BACKEND_URL4=http://192.168.0.10:9009/asr #cpu 9008-gpu
WS_URL=ws://localhost:8081
SERVER_PORT_WS=8081
SERVER_PORT_HTTP=8080

17
.vscode/launch.json vendored
View File

@ -30,11 +30,26 @@
"name": "node: Launch server.js",
"type": "node",
"request": "launch",
"program": "conda activate node && node web/server.js",
"program": "conda activate node && ${workspaceFolder}/web/server.js",
"console": "integratedTerminal",
"skipFiles": [
"<node_internals>/**"
]
},
{
"name": "conda task: Launch server.js",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/web/server.js",
// "preLaunchTask": "conda-activate",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"CONDA_ENV": "node", //?
//set env to dev
"NODE_ENV": "development"
}
},
{
"name": "Python Debugger: Python File",
"type": "debugpy",

28
.vscode/tasks.json vendored
View File

@ -86,17 +86,19 @@
"panel": "new"
},
},
{
"label": "conda-activate",
"type": "shell",
"command": "source ~/miniconda3/etc/profile.d/conda.sh && conda activate py && echo 'Activated Conda Environment (py)!'",
"problemMatcher": [],
"options": {
"shell": {
"executable": "/bin/bash",
"args": ["-c"]
}
}
}
]
{
"label": "conda-activate",
"type": "shell",
"command": "source ~/miniconda3/etc/profile.d/conda.sh && conda activate ${input:condaEnv} && echo 'Activated Conda Environment (${input:condaEnv})!'",
"problemMatcher": [],
}
],
"inputs": [
{
"id": "condaEnv",
"type": "promptString",
"description": "Enter the Conda environment name",
"default": "py"
}
]
}

View File

@ -9,7 +9,7 @@ services:
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
TTS_BACKEND_URL: http://192.168.0.10:9009/asr
# TTS_BACKEND_URL: http://192.168.0.10:9009/asr
WS_URL: ws://192.168.0.10:28081
SERVER_PORT_WS: 8081
SERVER_PORT_HTTP: 8080

11
package-lock.json generated
View File

@ -9,7 +9,7 @@
"version": "1.0.0",
"dependencies": {
"body-parser": "^1.20.2",
"dotenv": "^16.0.3",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"git": "^0.1.5",
"node-persist": "^3.1.3",
@ -246,11 +246,14 @@
}
},
"node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"version": "16.4.5",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/ecc-jsbn": {

View File

@ -9,7 +9,7 @@
},
"dependencies": {
"body-parser": "^1.20.2",
"dotenv": "^16.0.3",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"git": "^0.1.5",
"node-persist": "^3.1.3",

22
web/.env Normal file
View File

@ -0,0 +1,22 @@
TTS_BACKEND_URL=https://api.tts.d-popov.com/
WS_URL=ws://localhost:8081
SERVER_PORT_WS=8081
SERVER_PORT_HTTP=3005
# aider
AIDER_MODEL=
AIDER_4=false
#AIDER_35TURBO=
# OPENAI_API_KEY=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
# OPENAI_API_BASE=https://api.deepseek.com/v1
# OPENAI_API_KEY=sk-99df7736351f4536bd72cd64a416318a
# AIDER_MODEL=deepseek-coder #deepseek-coder, deepseek-chat
GROQ_API_KEY=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
aider --model groq/llama3-70b-8192
# List models available from Groq
aider --models groq/

View File

@ -61,6 +61,11 @@
onclick="copyToClipboard('transcription')">
Copy
</button>
<button id="clearButton"
class="absolute top-0 right-20 px-2 py-1 text-sm font-medium text-gray-700 bg-gray-200 hover:bg-gray-300 rounded-br-lg focus:outline-none"
onclick="transcription.value = ''">
Clear
</button>
</div>
<canvas id="canvas" class="w-full"></canvas>
<script>

View File

@ -1,6 +1,7 @@
//load .env file
if (require('dotenv')) {
require('dotenv').config()
const envFile =process.env.NODE_ENV === 'development' ? '.env.development' : '.env';
require('dotenv').config({ path: envFile });
}
console.log('Starting ws server on port ' + process.env.SERVER_PORT_WS);
@ -9,8 +10,9 @@ const wss = new WebSocket.Server({ port: process.env.SERVER_PORT_WS });
// console.log("ENV="+process.env)
console.log("TTS_BACKEND_URL=" + process.env.TTS_BACKEND_URL)
console.log("TTS_API_URL=" + process.env.TTS_API_URL)
console.log("WS_URL=" + process.env.WS_URL)
console.log("ENV_NAME=" + process.env.ENV_NAME)
let language = "en";
let storeRecordings = false;
@ -54,7 +56,7 @@ wss.on('connection', (ws, req) => {
console.log('(queue ' + queueCounter + ') Received ' + (data.length / 1024 / 1024).toFixed(3) + ' MB audio from client. Crrent language: ' + language, 'task: ' + task);
var request = require('request');
var endpoint = process.env.TTS_BACKEND_URL;
var endpoint = process.env.TTS_API_URL;
var formData = {
task: task,
language: language,
@ -113,7 +115,7 @@ wss.on('connection', (ws, req) => {
//record start time
var start = new Date().getTime();
queueCounter++;
request.post({ url: process.env.TTS_BACKEND_URL, formData: formData }, function optionalCallback(err, httpResponse, body) {
request.post({ url: process.env.TTS_API_URL, formData: formData }, function optionalCallback(err, httpResponse, body) {
queueCounter--;
if (err) {
return console.error('upload failed:', err);
@ -239,14 +241,14 @@ app.get('/test_ocr', (req, res) => {
formData.language = req.query.language;
}
var tts_url = process.env.TTS_BACKEND_URL;
var tts_url = process.env.TTS_API_URL;
if (req.query.ttsID != undefined) {
//1: TTS_BACKEND_URL
//2: TTS_BACKEND_URL2
//3: TTS_BACKEND_URL3
//4: TTS_BACKEND_URL4
//1: TTS_API_URL
//2: TTS_API_URL2
//3: TTS_API_URL3
//4: TTS_API_URL4
if (req.query.ttsID !== '1') {
tts_url = process.env['TTS_BACKEND_URL' + req.query.ttsID];
tts_url = process.env['TTS_API_URL' + req.query.ttsID];
}
}