wip
Browse files- public/sounds/intro_en.mp3 +0 -0
- public/sounds/intro_fr.mp3 +0 -0
- public/sounds/intro_spa.mp3 +0 -0
- src/app/api/voice/route.ts +5 -2
- src/app/page.tsx +1 -1
- src/components/intro/Intro.tsx +34 -1
public/sounds/intro_en.mp3
ADDED
Binary file (640 kB). View file
|
|
public/sounds/intro_fr.mp3
ADDED
Binary file (707 kB). View file
|
|
public/sounds/intro_spa.mp3
ADDED
Binary file (472 kB). View file
|
|
src/app/api/voice/route.ts
CHANGED
@@ -87,9 +87,12 @@ export async function POST(request: Request) {
|
|
87 |
}
|
88 |
|
89 |
const audioBuffer = await response.arrayBuffer();
|
90 |
-
return new
|
91 |
headers: {
|
92 |
-
'Content-Type': 'audio/mpeg'
|
|
|
|
|
|
|
93 |
}
|
94 |
});
|
95 |
|
|
|
87 |
}
|
88 |
|
89 |
const audioBuffer = await response.arrayBuffer();
|
90 |
+
return new Response(audioBuffer, {
|
91 |
headers: {
|
92 |
+
'Content-Type': 'audio/mpeg',
|
93 |
+
'Accept-Ranges': 'bytes',
|
94 |
+
'Content-Length': audioBuffer.byteLength.toString(),
|
95 |
+
'Cache-Control': 'no-cache'
|
96 |
}
|
97 |
});
|
98 |
|
src/app/page.tsx
CHANGED
@@ -34,7 +34,7 @@ interface Chat {
|
|
34 |
const intro = {
|
35 |
fr: {
|
36 |
title: "L'Avocat de l'IA",
|
37 |
-
description: `Daniel est un
|
38 |
start: "Commencer"
|
39 |
},
|
40 |
en: {
|
|
|
34 |
const intro = {
|
35 |
fr: {
|
36 |
title: "L'Avocat de l'IA",
|
37 |
+
description: `Daniel est un mec banale. Il n'a rien fait de mal.\nPourtant, il est convoqué aujourd'hui dans ce tribunal. Pauvre Daniel...`,
|
38 |
start: "Commencer"
|
39 |
},
|
40 |
en: {
|
src/components/intro/Intro.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
'use client';
|
2 |
-
import { FC } from 'react';
|
3 |
import Image from 'next/image';
|
4 |
|
5 |
|
@@ -39,10 +39,43 @@ const IntroScene: FC<IntroSceneProps> = ({
|
|
39 |
setNextScene,
|
40 |
story,
|
41 |
}) => {
|
|
|
|
|
42 |
const handleContinue = () => {
|
43 |
setNextScene();
|
44 |
};
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
return (
|
47 |
<div className="relative w-screen h-screen">
|
48 |
{/* Image de fond */}
|
|
|
1 |
'use client';
|
2 |
+
import { FC, useEffect, useRef } from 'react';
|
3 |
import Image from 'next/image';
|
4 |
|
5 |
|
|
|
39 |
setNextScene,
|
40 |
story,
|
41 |
}) => {
|
42 |
+
const audioRef = useRef<HTMLAudioElement | null>(null);
|
43 |
+
|
44 |
const handleContinue = () => {
|
45 |
setNextScene();
|
46 |
};
|
47 |
|
48 |
+
useEffect(() => {
|
49 |
+
|
50 |
+
let audio: HTMLAudioElement | undefined;
|
51 |
+
|
52 |
+
if (language === 'en') {
|
53 |
+
audio = new Audio('/sounds/intro_en.mp3');
|
54 |
+
} else if (language === 'fr') {
|
55 |
+
audio = new Audio('/sounds/intro_fr.mp3');
|
56 |
+
} else if (language === 'es') {
|
57 |
+
audio = new Audio('/sounds/intro_es.mp3');
|
58 |
+
}
|
59 |
+
|
60 |
+
if (!audio) return; // Add early return if no audio is set
|
61 |
+
|
62 |
+
const playAudio = () => {
|
63 |
+
audio.play().catch(error => {
|
64 |
+
console.log('Audio playback error:', error);
|
65 |
+
});
|
66 |
+
};
|
67 |
+
|
68 |
+
audio.addEventListener('canplaythrough', playAudio, { once: true });
|
69 |
+
|
70 |
+
return () => {
|
71 |
+
audio.removeEventListener('canplaythrough', playAudio);
|
72 |
+
if (audioRef.current) {
|
73 |
+
audioRef.current.pause();
|
74 |
+
audioRef.current.currentTime = 0;
|
75 |
+
}
|
76 |
+
};
|
77 |
+
}, []);
|
78 |
+
|
79 |
return (
|
80 |
<div className="relative w-screen h-screen">
|
81 |
{/* Image de fond */}
|