This commit is contained in:
Dmitry 2026-01-05 03:30:35 +03:00
parent 19dc953d6e
commit 4b6e1aa69c
3 changed files with 42 additions and 3 deletions

View file

@ -1,4 +1,6 @@
import { PrismaClient } from '@prisma/client';
import * as fs from 'fs';
import * as path from 'path';
const prisma = new PrismaClient();
@ -177,6 +179,41 @@ async function main() {
console.log('Family pack created:', familyPack);
// Read default questions from JSON file
// questions.json is in the project root, one level up from backend/
const questionsJsonPath = path.resolve(
process.cwd(),
'../questions.json',
);
const questionsJson = JSON.parse(
fs.readFileSync(questionsJsonPath, 'utf-8'),
);
// Transform questions: remove id field
const defaultQuestions = questionsJson.map((q: any) => ({
text: q.text,
answers: q.answers,
}));
// Create default question pack
const defaultPack = await prisma.questionPack.upsert({
where: { id: 'default-pack-1' },
update: {},
create: {
id: 'default-pack-1',
name: 'Новогодние вопросы',
description: 'Новогодние вопросы',
category: 'Новый год',
isPublic: true,
createdBy: demoUser.id,
questions: defaultQuestions,
questionCount: defaultQuestions.length,
rating: 5.0,
},
});
console.log('Default pack created:', defaultPack);
console.log('Seed completed successfully!');
}

View file

@ -8,7 +8,7 @@ import {
HttpStatus,
HttpException,
} from '@nestjs/common';
import { Response } from 'express';
import type { Response } from 'express';
import { VoiceService } from './voice.service';
@Controller('voice')

View file

@ -6,11 +6,13 @@ export class VoiceService {
private readonly voiceServiceUrl: string;
constructor(private configService: ConfigService) {
this.voiceServiceUrl = this.configService.get<string>('VOICE_SERVICE_HOST');
const voiceServiceHost = this.configService.get<string>('VOICE_SERVICE_HOST');
if (!this.voiceServiceUrl) {
if (!voiceServiceHost) {
throw new Error('VOICE_SERVICE_HOST environment variable is not set');
}
this.voiceServiceUrl = voiceServiceHost;
}
async generateTTS(text: string, voice: string = 'sarah'): Promise<Buffer> {