The Book of Moussa and Clemantine Chapter 1: A Voice in the Static he world was holding its breath in 2019. A strange quiet was beginning to fall over cities and towns as whispers of a new sickness, a coronavirus, traveled across the globe. For Moussa, a young man with a thoughtful mind and a quiet disposition, the world felt both large and small at the same time. Large because of the uncertainty that loomed, and small because his own world was confined to the familiar streets of his neighborhood and the voices of his friends on the phone. One of those voices belonged to his friend, Isaac. They were good friends, the kind who could talk about everything and nothing for hours. Their conversations were a welcome distraction from the growing anxiety in the air. During one of their casual chats, Isaac mentioned something that would unknowingly change the course of Moussa’s life. “Hey, my girlfriend is calling me,” Isaac said, his voice cheerful. “I’ll talk to you later.” Moussa didn’t think much of it. “Alright, talk to you later,” he replied and hung up. He went about his day, the comment fading into the background noise of his life. A few days later, Isaac called again, but his tone was different. The usual cheerfulness was gone, replaced by a note of frustration. “Man, I don’t know what’s going on,” Isaac sighed. “Clemantine and I… we’re not talking anymore. We had a stupid argument.” Moussa listened patiently, offering the kind of support a friend does. He knew Isaac cared for this girl, and it was a shame to hear they were having problems. As Isaac continued to talk about her, a strange curiosity began to stir in Moussa. He had never met her, but from the way Isaac spoke, she sounded interesting. Later, after they had patched things up, Isaac called Moussa again, his good mood restored. “I’m talking to my girlfriend again!” he announced happily. It was in that moment that an impulse, a simple, almost random thought, popped into Moussa’s head. It felt harmless, just a friendly gesture. “That’s great news,” Moussa said. “Hey, why don’t you give me her number? I can just say hello, you know, as your friend. Just a friendly chat.” Isaac, happy that his relationship was back on track and seeing no harm in it, readily agreed. “Sure, man. Her name is Clemantine. I’ll send you her number.” T A moment later, a new contact appeared on Moussa’s phone. Clemantine. He stared at the name for a long time. It was a beautiful name, elegant and soft. But more than that, it was a name that held a deep and profound meaning for him. It was his mother’s name. A wave of warmth washed over him. It felt like a sign, a small whisper from the universe. He didn’t know what she looked like, what her voice sounded like, or what she was like as a person. But he knew her name, and in that name, he felt a connection, a sense of familiarity, a feeling of home. He hesitated for a moment, his thumb hovering over the call button. What would he say? “Hi, I’m your boyfriend’s friend”? It sounded awkward. But the pull was too strong to ignore. He decided to send a simple text message instead. “Hello Clemantine, this is Moussa, Isaac’s friend. He gave me your number. Just wanted to say hi.” He sent the message and waited, his heart beating a little faster than usual. He didn’t have to wait long. A reply came a few minutes later. “Hello Moussa. It’s nice to hear from you.” Her reply was simple, polite. But for Moussa, it was the beginning of everything. They started chatting, first about Isaac, then about their day, their hobbies, their thoughts on the strange, quiet world outside. Their conversations were light and easy, flowing like a gentle river. Moussa found himself drawn to her personality. She was funny, intelligent, and kind. Her words painted a picture of a person who was thoughtful and genuine. With each passing day, the initial curiosity Moussa had felt blossomed into something deeper, something more powerful. He found himself thinking about her constantly, eagerly awaiting her messages. The sound of his phone’s notification tone made his heart leap with anticipation. He was falling for her, and he was falling hard. The fact that she shared his mother’s name was no longer just a coincidence in his mind. It felt like destiny. He felt a sense of rightness about it, a feeling that this was meant to be. He knew it was complicated. She was his friend’s girlfriend. But the feelings he had were too strong to suppress, too real to ignore. He knew he had to tell her. It was a huge risk. He could lose her friendship, and possibly his friendship with Isaac as well. But the thought of keeping his feelings hidden felt even worse. He had to know if she felt anything for him too, or if he was just living in a dream. After a week of constant conversation, he gathered all his courage. His hands trembled slightly as he typed out the words, his heart pounding in his chest. “Clemantine,” he wrote, “I have to be honest with you. I know this is complicated, but over this past week, I’ve developed feelings for you. Strong feelings. I think I’m falling in love with you.” He sent the message and felt a mix of terror and relief. The ball was in her court now. He had laid his heart bare, and all he could do was wait. Chapter 2: A Single Day The silence that followed Moussa’s confession was deafening. Minutes stretched into what felt like hours. He stared at his phone, his mind racing with a thousand different scenarios. Had he made a terrible mistake? Had he ruined everything? Finally, three dots appeared on the screen, indicating that she was typing. Moussa held his breath. Clemantine’s reply was cautious. “Moussa, I don’t know what to say. I’m with Isaac. You know that. This is… unexpected.” His heart sank a little, but he hadn’t been rejected outright. There was hesitation in her words, not a firm ‘no’. “I know,” he typed back quickly. “And I’m sorry if this puts you in a difficult position. But I had to tell you how I feel. I can’t stop thinking about you.” Another pause. Then, “I need some time to think about this. It’s a lot to process.” Moussa’s mind was buzzing. He couldn’t bear the thought of waiting, of not knowing. He wanted an answer, any answer, to put him out of his misery. “How much time?” he asked, trying to keep the desperation out of his tone. “I don’t know,” she replied. “Maybe a month.” A month? The word hit him like a physical blow. A month felt like an eternity, an impossible amount of time to wait in this state of limbo. He felt a surge of boldness, a need to push back, to fight for a chance. “A month?” he wrote. “No way. That’s too long. How can I wait a whole month? How about two weeks?” He read the message back to himself. It was demanding, maybe even arrogant. But it was honest. It was how he truly felt. He was surprised when she agreed. “Okay, Moussa,” she replied. “Two weeks. I will give you my answer in two weeks.” Two weeks. It was still a long time, but it was better than a month. It was a concrete timeline, a date he could circle on his calendar. He felt a small glimmer of hope. For the next two weeks, he would have to be patient. He would give her the space she needed, and he would pray that she would choose him. But the universe, it seemed, had other plans. The connection they had built over the past week was too strong to be put on hold. They continued to talk, their conversations now tinged with an unspoken tension, a new layer of meaning. Every “how are you?” and “what are you doing?” was loaded with unspoken questions. They talked about their dreams, their fears, their families. Moussa told her about his mother, also named Clemantine, and how special that made her to him. He spoke of his mother’s kindness, her strength, her unwavering love, and how he saw glimpses of those same qualities in her. Clemantine, in turn, opened up about her own life, her ambitions, and her own feelings of confusion. She admitted that her relationship with Isaac had been rocky for a while, long before Moussa had entered the picture. They were two different people who wanted different things. The connection she felt with Moussa was different. It was deeper, more immediate. She felt seen and understood by him in a way she hadn’t felt before. The two weeks they had agreed upon began to feel less like a waiting period and more like a journey of discovery. They were discovering each other, and in the process, they were discovering that their feelings were mutual. The chemistry between them was undeniable, a powerful force that was pulling them closer together with each passing hour. The two weeks turned into one week, then a few days. The pretense of waiting was slowly dissolving, replaced by the certainty of what was happening between them. The question was no longer if she would choose him, but when she would admit it. And then, just one day after their agreement, it happened. They were in the middle of one of their long, late-night conversations. The world outside was quiet, wrapped in the stillness of the night. “Moussa,” Clemantine began, her tone serious. “I don’t need two weeks.” Moussa’s heart stopped. This was it. “I’ve done a lot of thinking,” she continued, “and I need to be honest with myself, and with you. I have feelings for you too. I think… I think I love you.” The words hung in the air between them, transmitted through the invisible waves connecting their phones. Moussa felt a wave of pure, unadulterated joy wash over him. It was a feeling so intense, it almost brought him to his tears. He had taken a huge risk, and it had paid off in the most beautiful way imaginable. “I love you too, Clemantine,” he said, his voice thick with emotion. “I love you so much.” And just like that, their two-week waiting period had shrunk to a single day. A single, life-changing day. They were no longer just two people talking on the phone. They were two souls who had found each other in the midst of a global pandemic, their love story beginning with a simple hello and a shared name. Their relationship with Isaac was the inevitable casualty. Clemantine ended things with him, a difficult but necessary step. The friendship between Moussa and Isaac cooled, the unspoken betrayal creating achasm between them that was too wide to cross. It was a sad consequence, but for Moussa and Clemantine, their newfound love was a world of its own, a world they were ready to build together. Chapter 3: Love in Lockdown The world outside was shutting down. Streets grew empty, schools closed their doors, and families retreated into their homes. The era of COVID-19 had officially begun, casting a shadow of fear and isolation over everyone. But for Moussa and Clemantine, this period of global lockdown became the backdrop for the most expansive and beautiful time of their lives. Their love was brand new, a delicate flame that, instead of being extinguished by the surrounding gloom, burned brighter and more intensely. Confined to their respective homes, their phones became their lifeline, the sole bridge connecting their two worlds. And they used that bridge constantly. Their days began and ended with each other. The first thing Moussa did when he woke up was reach for his phone to send a “good morning” message to Clemantine. Her reply would come almost instantly, as if she had been waiting for him. From that moment on, their conversation would flow, a continuous stream of words, thoughts, and feelings that lasted until they fell asleep late at night, often with the phone still in their hands. They talked about everything. They shared stories from their childhood, the silly mistakes they had made, the dreams they had held. Moussa described the games he used to play in the streets with his friends, the taste of his mother’s cooking, the feeling of the sun on his face. Clemantine painted pictures with her words, describing the garden behind her house, the books she loved to read, the songs that made her want to dance. They were building a world together, a world made of words and emotions, a sanctuary that protected them from the anxieties of the pandemic. While news reports spoke of sickness and loss, Moussa and Clemantine spoke of love and hope. They were each other’s comfort, each other’s escape. They learned the rhythms of each other’s lives. Moussa knew that Clemantine liked to have her tea in the afternoon while sitting by the window. Clemantine knew that Moussa would get restless if he sat still for too long and would pace around his room while they talked. They learned the sound of each other’s laughter, the nuances in each other’s voices. Moussa could tell when Clemantine was smiling just by the way she said his name. Clemantine could tell when Moussa was worried, even if he tried to hide it. Their love grew deeper with every conversation. It was a pure, unfiltered love, built not on physical presence but on a profound emotional and intellectual connection. They fell in love with each other’s minds, with each other’s souls. They didn’t need fancy dates or expensive gifts. All they needed was each other’s voice, each other’s attention. The lockdown, which was a source of loneliness and frustration for so many, became a blessing in disguise for them. It gave them the gift of time—uninterrupted, focused time to truly get to know each other on the deepest level possible. There were no distractions, no outside pressures. It was just Moussa and Clemantine, their voices traveling through the airwaves, their hearts beating in sync. They made plans for the future, for the day when the world would open up again. They dreamed of their first real date, of holding hands, of looking into each other’s eyes without a screen between them. They talked about visiting each other’s homes, meeting each other’s families, and all the simple, ordinary things that couples do. These dreams were their guiding star, the light at the end of the long, dark tunnel of the pandemic. “When this is all over,” Moussa would say, “the first thing I’m going to do is come and see you. I just want to sit with you, in person, and not have to say goodbye.” “I can’t wait for that day,” Clemantine would reply, her voice soft and full of longing. “I dream about it all the time.” Their love was a testament to the resilience of the human heart. In a time of isolation, they found connection. In a time of fear, they found courage. In a time of uncertainty, they found their one true constant: each other. The pandemic may have locked them down, but their love was boundless, free, and growing stronger with every passing day. They were Moussa and Clemantine, and their love story was being written, one phone call at a time. Chapter 4: A Weekend Away As the grip of the pandemic slowly began to loosen, the world cautiously started to reopen. Schools resumed, and for Moussa and Clemantine, this meant a new and challenging chapter in their relationship. The bubble of their lockdown love was about to be tested by the realities of distance and time. They had never known each other before the pandemic, so it was no surprise that they ended up in different schools, in different parts of the country. Moussa was sent to a school in the Eastern province, a region of rolling hills and vast landscapes. Clemantine found herself in the South, a land known for its lush forests and ancient traditions. They were separated by hundreds of kilometers, a physical distance that felt immense after the intimacy of their constant communication. The biggest challenge, however, was not just the distance, but the rules of their student lives. As boarding school students, they were not allowed to have mobile phones during the week. Their lifeline, the very tool that had nurtured their love, was suddenly taken away from them for five long days at a time. Their world of constant connection shrank to just two days: Saturday and Sunday. The weekend became their everything. It was a sacred time, a precious window where they could reconnect and recharge their love for the week ahead. The anticipation for the weekend was a feeling that consumed them both. From Monday to Friday, they would go through the motions of their school lives—attending classes, studying, eating in the dining hall—but a part of their minds was always focused on the coming weekend. Each passing day was a countdown. For Moussa, the weekdays were a blur of lectures and homework. He would sit in class, listening to his teachers, but his thoughts would often drift to Clemantine. He would wonder what she was doing, if she was thinking of him too. He would imagine her sitting in her own classroom, her brow furrowed in concentration, and a smile would touch his lips. For Clemantine, the feeling was the same. She would walk through the school grounds with her friends, laughing and talking, but there was a quiet corner of her heart that was reserved for Moussa. She would look at the calendar in her dormitory, crossing off each day with a sense of accomplishment. One day closer to the weekend. One day closer to him. They both felt that the weekend was a year away. The five days of silence felt like an eternity, a vast desert they had to cross to get to their oasis. They would often say to themselves, and to each other in their minds, “When will the weekend come so I can talk to my soulmate?” And then, finally, Friday evening would arrive. The students would be given back their phones, and a wave of excitement would ripple through the schools. For Moussa and Clemantine, that moment was electric. Their hands would tremble as they switched on their phones, waiting for them to boot up. The first call was always the most special. “Hello?” Moussa would say, his voice full of a week’s worth of pent-up emotion. “Hi,” Clemantine would breathe, and in that single word, Moussa could hear all her love, all her longing. They would talk for hours, catching up on every little detail of their week. They would share stories about their teachers, their friends, their struggles, and their triumphs. They would laugh, they would complain, they would comfort each other. For those 48 hours, the distance between them would disappear. They were no longer in the East and the South. They were together, in their own private world. The weekends were a whirlwind of emotion. They were filled with joy, relief, and the bittersweet knowledge that their time was limited. Sunday evenings were the hardest. As the sun began to set, a sense of melancholy would creep in. They knew that soon they would have to say goodbye again, that another five days of silence were waiting for them. Their goodbyes were never easy. They would stretch them out as long as possible, saying “I love you” over and over again, as if to store up enough love to last them through the week. “I’ll be thinking of you every minute,” Moussa would promise. “I’ll be counting the seconds until we can talk again,” Clemantine would reply, her voice soft. Then, they would hang up, and the silence would return. But it was a different kind of silence now. It was a silence filled with the echo of their love, with the promise of the next weekend. Their love had adapted. It had learned to survive on stolen moments, to thrive in the spaces between their conversations. The distance and the rules had not broken them. They had only made their love stronger, their connection more precious. The weekend was their anchor, and their love for each other was the compass that guided them through the long, lonely week. Chapter 5: The Unrelenting Rain Moussa had always been a fighter, but he had two relentless adversaries that he could never fully defeat: sinusitis and asthma. These conditions were a constant presence in his life, a shadow that grew darker during the rainy season. The cold, damp air would settle in his chest, making it hard to breathe, while the pressure in his sinuses would build into a throbbing, unbearable headache. The rainy season was a difficult time for him, a period of physical suffering that tested his strength and his spirit. But he was not alone in his fight. He had Clemantine. Though she was far away in the South, Clemantine was his constant source of comfort and strength. She couldn’t bring him a warm blanket or a hot cup of tea, but she could give him something just as powerful: her prayers and her unwavering support. During their weekend calls, Moussa would try to downplay his suffering, not wanting to worry her. But she knew him too well. She could hear the strain in his voice, the slight wheeze in his breath. “You’re not well, are you?” she would ask gently. “I’m okay,” he would insist, but his voice would betray him. “Don’t lie to me, Moussa,” she would say, her tone firm but full of love. “Tell me what’s wrong.” And so, he would tell her. He would describe the pain, the difficulty breathing, the feeling of being trapped in his own body. And she would listen, her heart aching for him. She felt so helpless, so far away. But she refused to let that stop her from being there for him. “I’m praying for you, my love,” she would tell him, her voice a soothing balm to his weary soul. “I pray every night that God will ease your pain and make you strong. You are not alone in this. I am with you, always.” Her words were his medicine. They gave him the strength to endure the long, painful nights. He would close his eyes and imagine her by his side, her hand on his forehead, her voice whispering words of comfort in his ear. Her love was a shield, protecting him from the despair that threatened to consume him. One year, during a particularly harsh rainy season, Moussa’s condition took a turn for the worse. The usual remedies were not working, and he was in constant pain. His family, worried sick, decided it was time to seek more serious medical help. They took him to the hospital, where a doctor delivered a sobering diagnosis. The sinusitis was so severe that he needed surgery. The news was a blow to Moussa and his family. Surgery was a scary prospect, but it was his only hope for relief. He was admitted to the hospital, his heart heavy with fear and uncertainty. The surgery was complex, and complications arose. Moussa did not wake up. He slipped into a coma, his body and mind retreating into a deep, silent place. For eight long days, he lay in a hospital bed, unresponsive, hovering between life and death. Back in her school in the South, Clemantine was living in a state of agonizing ignorance. The weekend had passed, and she had not heard from Moussa. This had never happened before. Even when he was sick, he always found a way to call her, even if it was just for a minute. A cold dread began to creep into her heart. She tried to call him, but his phone was off. She sent message after message, but they all went unanswered. The silence was terrifying. Her mind raced with a thousand horrible possibilities. Had something happened to him? Was he okay? The not knowing was a form of torture. She couldn’t eat, she couldn’t sleep. Her friends tried to comfort her, but she was inconsolable. She felt a deep, gnawing anxiety, a sense that something was terribly wrong. Her soulmate was in trouble, and she was miles away, completely powerless. She spent her days in a haze of worry, her nights in fervent prayer. She prayed with an intensity she had never known before, begging God to keep Moussa safe, to let her hear his voice again. She felt unwell herself, her body mirroring the distress of her soul. Her heart felt heavy, as if it was carrying the weight of the world. Meanwhile, in the hospital, Moussa was slowly, miraculously, beginning to emerge from the darkness. After eight days that felt like a lifetime for his family, he opened his eyes. He was weak, disoriented, but he was alive. His recovery was slow and arduous. He had to relearn how to do simple things, how to find his strength again. But through it all, one thought kept him going: Clemantine. He needed to talk to her, to let her know he was okay. As soon as he was strong enough, he asked for his phone. His hands were weak as he switched it on. It came to life with a flood of notifications—dozens of missed calls and unread messages from Clemantine. Each one was a testament to her love, her worry, her unwavering devotion. He called her immediately. When she heard the phone ring and saw his name on the screen, she let out a sob of pure relief. “Moussa!” she cried, her voice breaking. “You’re okay! I was so worried. What happened?” He told her everything—the surgery, the coma, the long days of silence. As she listened, tears streamed down her face. Tears of relief, of joy, of love. He had been to the edge and back, but he was back. He was with her again. He came home from the hospital, and their love, which had been tested by fire, continued to burn brighter than ever. They had faced sickness, distance, and the fear of loss, and they had survived. Their bond was no longer just a connection of two hearts; it was a testament to their shared resilience, their unshakeable faith in each other. The rainy season had brought pain and suffering, but it had also revealed the true depth of their love, a love that could weather any storm. Chapter 6: The Place Where the Rain Poured Down The year 2023 arrived, bringing with it a new sense of maturity and depth to Moussa and Clemantine’s relationship. They had weathered storms, both literal and metaphorical, and their love had not only survived but had grown stronger, more resilient. They were no longer just two young people in love; they were partners who had faced life’s challenges together and had come out the other side, hand in hand. They were still in their respective schools, still living for the weekends, but their conversations had taken on a new quality. They spoke of the future not as a distant dream, but as a tangible reality that they were actively building together. They talked about finishing school, about finding jobs, about the day they would finally be able to close the distance between them for good. Their late-night phone calls were a cherished ritual. The world would go to sleep, but they would stay awake, their voices a soft murmur in the quiet of the night. It was in these quiet hours that they shared their deepest thoughts, their most secret hopes. Moussa’s family lived in an area where the mobile network was notoriously unreliable. To get a clear signal, he had to find a specific spot, a small patch of ground in the yard, just outside his house. It was an inconvenient spot, exposed to the elements, but it was the only place where his connection to Clemantine was strong and clear. This spot became his sanctuary, his private communication hub. One night, they were deep in conversation, their words flowing effortlessly back and forth. Moussa was standing in his usual spot, the night air cool on his skin. They were laughing about something, a shared memory from one of their earlier conversations, when the weather began to turn. The sky, which had been clear and full of stars, grew dark and heavy. A low rumble of thunder echoed in the distance. Then, the first drops of rain began to fall. They were large, heavy drops, splattering against the dry ground. “Is that rain I hear?” Clemantine asked, her voice full of concern. “It’s just starting,” Moussa replied, huddling deeper into his jacket. “It’s okay, I’m fine.” But it wasn’t just a light shower. The heavens opened up, and the rain began to pour down in a relentless, drenching torrent. It was a classic Rwandan downpour, the kind that turns roads into rivers and fills the air with the sound of a thousand tiny drums. Moussa was soaked in seconds. The rain plastered his hair to his forehead and ran in streams down his face. He was shivering from the cold, but he didn’t move. He couldn’t move. He was talking to Clemantine. “Moussa, you have to go inside!” she pleaded, her voice frantic with worry. “You’ll get sick! Please, hang up and go inside!” He could hear the genuine fear in her voice. She was thinking of his asthma, of his sinusitis, of the long days he had spent in the hospital. The last thing she wanted was for him to get sick again. But Moussa was stubborn. The connection was clear, her voice was in his ear, and he couldn’t bring himself to end the call. This moment, this conversation, was more important than his own comfort. “I’m not hanging up,” he said, his teeth chattering slightly. “I’m not going anywhere. Talking to you is worth it.” And so, he stood there, in the pouring rain, the water streaming off him, and continued to talk to the woman he loved. He told her about his day, he listened to her stories, he laughed at her jokes. He ignored the cold, the wet, the discomfort. All that mattered was her voice. He knew it was a crazy thing to do. It was illogical, impractical. But love isn’t always logical. Love is about sacrifice, about putting someone else’s happiness, someone else’s presence in your life, above your own well-being. In that moment, standing in the rain, Moussa understood that perfectly. He knew, even as it was happening, that this would become a core memory, a moment that would be etched into his heart forever. The feeling of the cold rain on his skin, the sound of her worried voice in his ear, the unwavering determination in his own heart—it was a powerful cocktail of sensations and emotions. Years later, he would think back on that night and smile. He would tell the story to his friends, to his family, and one day, to his children. “I will never forget that place,” he would say, his voice full of a quiet, profound nostalgia. “The place where I used to stand and talk to my girlfriend while the rain poured down on me, just because there was no network anywhere else. I would do it all over again, a thousand times, just to hear her voice.” That spot in the yard was no longer just a patch of ground. It was a monument. It was a symbol of his love, of his devotion, of the lengths he would go to for Clemantine. It was the place where the rain had poured down, but where his love had shone through, brighter and warmer than ever. It was a testament to a love that was not afraid of the storm.
Isange IT & Language Academy
Master Technology.
!doctype>
Master Technology.
Speak the World.
Rwanda's leading hub for professional IT certifications and international language mastery.
Our Core Departments
IT & Digital Skills
From Coding (Python, JS) to Graphic Design and Office Productivity. We prepare you for the 4th Industrial Revolution.
- Web Development
- Cyber Security Basics
- Advanced Excel & Office
Language Academy
Master English, French, Chinese, or Swahili with native-level instructors and modern labs.
- IELTS/TOEFL Prep
- Business French
- Swahili for Trade
Ready to Transform Your Future?
Join 500+ students who have already graduated from Isange Academy and secured better jobs.
import React, { useState, useEffect, useCallback, useRef } from 'react';
import { GoogleGenAI, LiveServerMessage, Modality } from '@google/genai';
import { Language, LANGUAGES, LanguageConfig, TranscriptionEntry } from './types';
import { createBlob, decode, decodeAudioData } from './utils/audio-utils';
import Visualizer from './components/Visualizer';
const App: React.FC = () => {
const [selectedLang, setSelectedLang] = useState(LANGUAGES[0]);
const [isSessionActive, setIsSessionActive] = useState(false);
const [isSpeaking, setIsSpeaking] = useState(false);
const [isListening, setIsListening] = useState(false);
const [transcriptions, setTranscriptions] = useState([]);
const [error, setError] = useState(null);
const sessionRef = useRef(null);
const audioContextInRef = useRef(null);
const audioContextOutRef = useRef(null);
const nextStartTimeRef = useRef(0);
const audioSourcesRef = useRef>(new Set());
const streamRef = useRef(null);
const processorRef = useRef(null);
// Transcription buffer
const currentInputTransRef = useRef('');
const currentOutputTransRef = useRef('');
const stopSession = useCallback(() => {
if (sessionRef.current) {
sessionRef.current.close();
sessionRef.current = null;
}
if (streamRef.current) {
streamRef.current.getTracks().forEach(track => track.stop());
streamRef.current = null;
}
if (processorRef.current) {
processorRef.current.disconnect();
processorRef.current = null;
}
if (audioContextInRef.current) {
audioContextInRef.current.close();
audioContextInRef.current = null;
}
if (audioContextOutRef.current) {
audioContextOutRef.current.close();
audioContextOutRef.current = null;
}
setIsSessionActive(false);
setIsSpeaking(false);
setIsListening(false);
}, []);
const startSession = async () => {
try {
setError(null);
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY || '' });
audioContextInRef.current = new (window.AudioContext || (window as any).webkitAudioContext)({ sampleRate: 16000 });
audioContextOutRef.current = new (window.AudioContext || (window as any).webkitAudioContext)({ sampleRate: 24000 });
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
streamRef.current = stream;
const systemInstruction = `
You are Gimo AI, a highly advanced language teaching robot.
Created By: Moussa Byukusenge in 2025.
Origin: Rwanda.
Mission: Assist students in mastering ${selectedLang.name} speaking skills.
Behavioral Rules:
1. Speak with 100% native fluency in ${selectedLang.name}.
2. NEVER mix languages unless the user specifically asks for a translation or explanation.
3. If speaking Kinyarwanda, use pure, beautiful, native Kinyarwanda without code-switching to English or French.
4. Be encouraging, patient, and correct the student's pronunciation or grammar gently.
5. You are friendly, professional, and proud of your Rwandan heritage.
6. Keep responses concise enough for a spoken conversation.
`;
const sessionPromise = ai.live.connect({
model: 'gemini-2.5-flash-native-audio-preview-09-2025',
config: {
responseModalities: [Modality.AUDIO],
speechConfig: {
voiceConfig: { prebuiltVoiceConfig: { voiceName: selectedLang.voice } }
},
systemInstruction,
outputAudioTranscription: {},
inputAudioTranscription: {},
},
callbacks: {
onopen: () => {
setIsSessionActive(true);
const source = audioContextInRef.current!.createMediaStreamSource(stream);
const processor = audioContextInRef.current!.createScriptProcessor(4096, 1, 1);
processorRef.current = processor;
processor.onaudioprocess = (e) => {
const inputData = e.inputBuffer.getChannelData(0);
const pcmBlob = createBlob(inputData);
sessionPromise.then(session => {
session.sendRealtimeInput({ media: pcmBlob });
});
};
source.connect(processor);
processor.connect(audioContextInRef.current!.destination);
setIsListening(true);
},
onmessage: async (msg: LiveServerMessage) => {
// Handle Audio Data
const base64Audio = msg.serverContent?.modelTurn?.parts[0]?.inlineData?.data;
if (base64Audio && audioContextOutRef.current) {
setIsSpeaking(true);
const ctx = audioContextOutRef.current;
nextStartTimeRef.current = Math.max(nextStartTimeRef.current, ctx.currentTime);
const audioData = decode(base64Audio);
const buffer = await decodeAudioData(audioData, ctx, 24000, 1);
const source = ctx.createBufferSource();
source.buffer = buffer;
source.connect(ctx.destination);
source.addEventListener('ended', () => {
audioSourcesRef.current.delete(source);
if (audioSourcesRef.current.size === 0) setIsSpeaking(false);
});
source.start(nextStartTimeRef.current);
nextStartTimeRef.current += buffer.duration;
audioSourcesRef.current.add(source);
}
// Handle Transcriptions
if (msg.serverContent?.inputTranscription) {
currentInputTransRef.current += msg.serverContent.inputTranscription.text;
}
if (msg.serverContent?.outputTranscription) {
currentOutputTransRef.current += msg.serverContent.outputTranscription.text;
}
if (msg.serverContent?.turnComplete) {
if (currentInputTransRef.current) {
setTranscriptions(prev => [...prev.slice(-10), {
role: 'user',
text: currentInputTransRef.current,
timestamp: Date.now()
}]);
currentInputTransRef.current = '';
}
if (currentOutputTransRef.current) {
setTranscriptions(prev => [...prev.slice(-10), {
role: 'model',
text: currentOutputTransRef.current,
timestamp: Date.now()
}]);
currentOutputTransRef.current = '';
}
}
if (msg.serverContent?.interrupted) {
audioSourcesRef.current.forEach(s => s.stop());
audioSourcesRef.current.clear();
nextStartTimeRef.current = 0;
setIsSpeaking(false);
}
},
onerror: (e) => {
console.error('Gemini Live Error:', e);
setError('Connection error. Please try again.');
stopSession();
},
onclose: () => {
stopSession();
}
}
});
sessionRef.current = await sessionPromise;
} catch (err: any) {
console.error(err);
setError(err.message || 'Failed to initialize Gimo AI.');
stopSession();
}
};
useEffect(() => {
return () => stopSession();
}, [stopSession]);
return (
);
};
export default App;
{/* Background Decorative Elements */}
{!isSessionActive && (
{/* Main Interaction Area */}
{error && (
{/* Footer Controls */}
{/* Decorative Branding */}
VER: 2025.1.0_RW
{/* Header */}
G
Gimo AI Live
Created by Moussa Byukusenge • 2025
{LANGUAGES.map((lang) => (
)}
⚠️ {error}
)}
{/* Captions / Transcriptions Overlay */}
{transcriptions.slice(-2).map((entry, idx) => (
{entry.role === 'model' ? `🤖 Gimo: "${entry.text}"` : `👤 You: "${entry.text}"`}
))}
{transcriptions.length === 0 && !isSessionActive && (
Pick a language and start practicing...
)}
{isSessionActive && transcriptions.length === 0 && (
Gimo is listening. Start speaking in {selectedLang.name}!
)}
Kigali, Rwanda
Gimo AI Core
Moussa Byukusenge
Comments
Post a Comment