Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] AI 요약이 제대로 응답하지 않던 오류 수정 #370

Merged
merged 8 commits into from
Dec 4, 2024
2 changes: 1 addition & 1 deletion apps/api/src/entity/summary.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Summary {
@Column('varchar')
audioUrl: string;

@Column('json', { nullable: true })
@Column('text', { nullable: true })
summaryText: string[];

@CreateDateColumn({ type: 'timestamp', name: 'created_at' })
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/stream/stream.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class StreamController {

@Get('summary/:ticleId')
async getSummaryByTicleId(@Param('ticleId') ticleId: number) {
const text = await this.streamService.getSummaryText(ticleId);
return { summary: text };
const summary = await this.streamService.getSummary(ticleId);
return summary;
}
}
5 changes: 3 additions & 2 deletions apps/api/src/stream/stream.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ export class StreamService {
}
}

async getSummaryText(ticleId: number) {
async getSummary(ticleId: number) {
const summary = await this.summaryRepository.findOne({
where: { ticle: { id: ticleId } },
});
return summary.summaryText;

return summary;
}

async updateSummaryText(summary: Summary, summaryText: string[]) {
Expand Down
14 changes: 11 additions & 3 deletions apps/web/src/components/dashboard/AiSummaryDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ function AiSummaryDialog({ isOpen, onClose, ticleId }: AiSummaryDialogProps) {
<Dialog.Title align="center">AI 음성 요약</Dialog.Title>
<Dialog.Close onClose={onClose} />
<Dialog.Content className="custom-scrollbar overflow-y-scroll">
{!data || data?.summary.length === 0 ? (
{!data && (
<div className="flex h-[20rem] w-full flex-col items-center justify-center gap-10">
<Loading color="primary" />
<span className="whitespace-pre text-center text-title1 text-primary">
AI 요약을 처리중이에요.
</span>
</div>
) : (
<p className="whitespace-pre text-body1">{data?.summary[0]}</p>
)}
{data && !data.summaryText && (
<div className="flex h-[20rem] w-full flex-col items-center justify-center gap-10">
<span className="whitespace-pre text-center text-title1 text-primary">
AI 요약 결과가 없어요.
</span>
</div>
)}
{data && data.summaryText && (
<p className="whitespace-pre text-body1">{data.summaryText}</p>
)}
</Dialog.Content>
</Dialog.Root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

stream?.getTracks().forEach((track) => track.stop());

const cameraStream = await getCameraStream({ video: { deviceId: selectedVideoDeviceId } });
const cameraStream = await getCameraStream({ deviceId: selectedVideoDeviceId });

videoRef.current.srcObject = cameraStream;

Expand All @@ -26,8 +26,14 @@
};

getStream();
}, [selectedVideoDeviceId]);

Check warning on line 29 in apps/web/src/components/live/SettingDialog/SelectMedia.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook useEffect has a missing dependency: 'stream'. Either include it or remove the dependency array

useEffect(() => {
return () => {
stream?.getTracks().forEach((track) => track.stop());
};
}, [stream]);

return (
<div className="flex h-full flex-col gap-y-4 overflow-y-auto">
<div>
Expand Down
34 changes: 7 additions & 27 deletions apps/web/src/hooks/useMediaTracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,25 @@ const useMediaTracks = () => {
);

const getCameraTrack = async () => {
if (!selectedVideoDeviceId) {
return;
}
const options = selectedVideoDeviceId ? { deviceId: selectedVideoDeviceId } : {};

const stream = await getCameraStream({
video: { deviceId: selectedVideoDeviceId },
});
const stream = await getCameraStream(options);
const track = stream.getVideoTracks()[0];

if (!track) {
return;
}
if (!track) return;

setVideo({ stream, paused: true });

return track;
};

const getAudioTrack = async () => {
if (!selectedAudioDeviceId) {
return;
}
const options = selectedAudioDeviceId ? { deviceId: selectedAudioDeviceId } : {};

const stream = await getMicStream({
audio: {
deviceId: {
exact: selectedAudioDeviceId,
ideal: selectedAudioDeviceId,
},
},
});
const stream = await getMicStream(options);

const track = stream.getAudioTracks()[0];

if (!track) {
return;
}
if (!track) return;

setAudio({ stream, paused: true });

Expand All @@ -83,9 +65,7 @@ const useMediaTracks = () => {

const track = stream.getVideoTracks()[0];

if (!track) {
return;
}
if (!track) return;

setScreen({ stream, paused: false });

Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DEFAULT_SCREEN_CONSTRAINTS: MediaTrackConstraints = {
frameRate: { max: 30, ideal: 15 },
};

const getCameraStream = async (options: MediaStreamConstraints = {}) => {
const getCameraStream = async (options: MediaTrackConstraints = {}) => {
return navigator.mediaDevices.getUserMedia({
video: {
...DEFAULT_VIDEO_CONSTRAINTS,
Expand All @@ -28,7 +28,7 @@ const getCameraStream = async (options: MediaStreamConstraints = {}) => {
});
};

const getMicStream = async (options: MediaStreamConstraints = {}) => {
const getMicStream = async (options: MediaTrackConstraints = {}) => {
return navigator.mediaDevices.getUserMedia({
audio: {
...DEFAULT_AUDIO_CONSTRAINTS,
Expand All @@ -37,7 +37,7 @@ const getMicStream = async (options: MediaStreamConstraints = {}) => {
});
};

const getScreenStream = async (options: MediaStreamConstraints = {}) => {
const getScreenStream = async (options: MediaTrackConstraints = {}) => {
return navigator.mediaDevices.getDisplayMedia({
video: {
...DEFAULT_SCREEN_CONSTRAINTS,
Expand Down
11 changes: 8 additions & 3 deletions packages/types/src/dashboard/getDashboardList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ export const DashboardApplicantsResponseSchema = z.array(

export type DashboardApplicantsResponse = z.infer<typeof DashboardApplicantsResponseSchema>;

export const DashboardAiSummaryResponseSchema = z.object({
summary: z.array(z.string()),
});
export const DashboardAiSummaryResponseSchema = z
.object({
id: z.number(),
summaryText: z.string().nullable(),
audioUrl: z.string(),
createdAt: z.string().datetime(),
})
.nullable();

export type DashboardAiSummaryResponse = z.infer<typeof DashboardAiSummaryResponseSchema>;
Loading