feat: Enhance speech and AI configuration with advanced environment settings
- Update `.env.example` with comprehensive speech and AI configuration options - Modify Docker Compose speech configuration for more flexible audio and ASR settings - Enhance Dockerfile to support Python virtual environment and speech dependencies - Refactor environment loading to use Bun's file system utilities - Improve device listing tool with more detailed device statistics - Add support for multiple AI models and dynamic configuration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { config as dotenvConfig } from "dotenv";
|
||||
import fs from "fs";
|
||||
import { file } from "bun";
|
||||
import path from "path";
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ const ENV_FILE_MAPPING: Record<string, string> = {
|
||||
* Loads environment variables from the appropriate files based on NODE_ENV.
|
||||
* First loads environment-specific file, then overrides with generic .env if it exists.
|
||||
*/
|
||||
export function loadEnvironmentVariables() {
|
||||
export async function loadEnvironmentVariables() {
|
||||
// Determine the current environment (default to 'development')
|
||||
const nodeEnv = (process.env.NODE_ENV || "development").toLowerCase();
|
||||
|
||||
@@ -29,19 +29,29 @@ export function loadEnvironmentVariables() {
|
||||
const envPath = path.resolve(process.cwd(), envFile);
|
||||
|
||||
// Load the environment-specific file if it exists
|
||||
if (fs.existsSync(envPath)) {
|
||||
dotenvConfig({ path: envPath });
|
||||
console.log(`Loaded environment variables from ${envFile}`);
|
||||
} else {
|
||||
console.warn(`Environment-specific file ${envFile} not found.`);
|
||||
try {
|
||||
const envFileExists = await file(envPath).exists();
|
||||
if (envFileExists) {
|
||||
dotenvConfig({ path: envPath });
|
||||
console.log(`Loaded environment variables from ${envFile}`);
|
||||
} else {
|
||||
console.warn(`Environment-specific file ${envFile} not found.`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Error checking environment file ${envFile}:`, error);
|
||||
}
|
||||
|
||||
// Finally, check if there is a generic .env file present
|
||||
// If so, load it with the override option, so its values take precedence
|
||||
const genericEnvPath = path.resolve(process.cwd(), ".env");
|
||||
if (fs.existsSync(genericEnvPath)) {
|
||||
dotenvConfig({ path: genericEnvPath, override: true });
|
||||
console.log("Loaded and overrode with generic .env file");
|
||||
try {
|
||||
const genericEnvExists = await file(genericEnvPath).exists();
|
||||
if (genericEnvExists) {
|
||||
dotenvConfig({ path: genericEnvPath, override: true });
|
||||
console.log("Loaded and overrode with generic .env file");
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Error checking generic .env file:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user