voice
This commit is contained in:
parent
19dc953d6e
commit
4b6e1aa69c
3 changed files with 42 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
|
|
@ -177,6 +179,41 @@ async function main() {
|
||||||
|
|
||||||
console.log('Family pack created:', familyPack);
|
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!');
|
console.log('Seed completed successfully!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
HttpException,
|
HttpException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import { VoiceService } from './voice.service';
|
import { VoiceService } from './voice.service';
|
||||||
|
|
||||||
@Controller('voice')
|
@Controller('voice')
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ export class VoiceService {
|
||||||
private readonly voiceServiceUrl: string;
|
private readonly voiceServiceUrl: string;
|
||||||
|
|
||||||
constructor(private configService: ConfigService) {
|
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');
|
throw new Error('VOICE_SERVICE_HOST environment variable is not set');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.voiceServiceUrl = voiceServiceHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateTTS(text: string, voice: string = 'sarah'): Promise<Buffer> {
|
async generateTTS(text: string, voice: string = 'sarah'): Promise<Buffer> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue