Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/note.picotech.app/public_html/src/controllers/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const { Transcript, Recording } = require('../models');
const { AppError, catchAsync } = require('../middleware/errorHandler');
const { generateTranscription } = require('../services/transcriptionService');
exports.getRecordingTranscript = catchAsync(async (req, res, next) => {
try {
const { recordingId } = req.params;
const transcript = await Transcript.findOne({
where: { recording_id: recordingId }
});
if (!transcript) {
throw new AppError('Transcript not found', 404);
}
res.json({
success: true,
data: transcript
});
} catch (error) {
next(error);
}
});
exports.getMeetingTranscripts = catchAsync(async (req, res, next) => {
try {
const { meetingId } = req.params;
const transcripts = await Transcript.findAll({
where: { meeting_id: meetingId },
attributes: ['id', 'recording_id','meeting_id','content','created_at','updated_at'],
order: [['created_at', 'ASC']]
});
if (!transcripts) {
throw new AppError('Transcript not found', 404);
}
res.json({
success: true,
data: {transcripts:transcripts}
});
} catch (error) {
next(error);
}
});
exports.generateTranscript = catchAsync(async (req, res, next) => {
try {
const { recordingId } = req.params;
const recording = await Recording.findByPk(recordingId);
if (!recording) {
throw new AppError('Recording not found', 404);
}
// Check if transcript already exists
const existingTranscript = await Transcript.findOne({
where: { recording_id: recordingId }
});
if (existingTranscript) {
throw new AppError('Transcript already exists', 400);
}
// Generate transcript
const transcriptionResult = await generateTranscription(recording.file_path);
const transcript = await Transcript.create({
recording_id: recordingId,
meeting_id: recording.meeting_id,
content: transcriptionResult.text,
speaker_data: transcriptionResult.speakers,
confidence: transcriptionResult.confidence,
language: transcriptionResult.language
});
res.status(201).json({
success: true,
data: transcript
});
} catch (error) {
next(error);
}
});
exports.getTranscript = catchAsync(async (req, res, next) => {
try {
const transcript = await Transcript.findByPk(req.params.id);
if (!transcript) {
throw new AppError('Transcript not found', 404);
}
res.json({
success: true,
data: transcript
});
} catch (error) {
next(error);
}
});
exports.updateTranscript = catchAsync(async (req, res, next) => {
try {
const { content, speaker_data } = req.body;
const transcript = await Transcript.findByPk(req.params.id);
if (!transcript) {
throw new AppError('Transcript not found', 404);
}
await transcript.update({
content,
speaker_data
});
res.json({
success: true,
data: transcript
});
} catch (error) {
next(error);
}
});
exports.searchTranscripts = catchAsync(async (req, res, next) => {
try {
const { query, meetingId } = req.query;
const where = {};
if (meetingId) where.meeting_id = meetingId;
if (query) {
where.content = { [Op.like]: `%${query}%` };
}
const transcripts = await Transcript.findAll({ where });
res.json({
success: true,
data: transcripts
});
} catch (error) {
next(error);
}
}); |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0038 ]-- |