techtalk-fluency-factory / practice.html
cuongtranzi's picture
using gemini api to learning and voice specking check
ab1aa70 verified
Raw History Blame Contribute Delete
14.6 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practice - TechTalk Fluency Factory</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.gradient-text {
background: linear-gradient(90deg, #3b82f6, #8b5cf6);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.speech-bubble {
position: relative;
background: #3b82f6;
color: white;
border-radius: 1rem;
padding: 1rem;
margin: 1rem 0;
}
#waveform {
height: 100px;
background: #f1f5f9;
border-radius: 0.5rem;
margin: 1rem 0;
}
</style>
</head>
<body class="bg-gray-50">
<header class="bg-white shadow-sm sticky top-0 z-50">
<div class="container mx-auto px-4 py-4 flex justify-between items-center">
<div class="flex items-center space-x-2">
<i data-feather="mic" class="text-blue-500"></i>
<h1 class="text-2xl font-bold gradient-text">TechTalk Fluency</h1>
</div>
<nav class="hidden md:flex space-x-8">
<a href="index.html" class="text-gray-700 hover:text-blue-500 font-medium">Home</a>
<a href="courses.html" class="text-gray-700 hover:text-blue-500 font-medium">Courses</a>
<a href="practice.html" class="text-blue-500 font-medium">Practice</a>
<a href="#" class="text-gray-700 hover:text-blue-500 font-medium">Community</a>
</nav>
<div class="flex items-center space-x-4">
<button class="px-4 py-2 text-blue-500 font-medium rounded-full hover:bg-blue-50">Login</button>
<button class="px-4 py-2 bg-blue-500 text-white font-medium rounded-full hover:bg-blue-600">Sign Up</button>
<button class="md:hidden">
<i data-feather="menu"></i>
</button>
</div>
</div>
</header>
<main class="container mx-auto px-4 py-12">
<div class="mb-12">
<h1 class="text-4xl font-bold text-gray-900 mb-4">AI-Powered Speaking Practice</h1>
<p class="text-xl text-gray-600">Get real-time feedback on your technical English with Gemini AI</p>
</div>
<div class="grid md:grid-cols-2 gap-8">
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Practice Scenario</h2>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2">Select Scenario</label>
<select id="scenario-select" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500">
<option value="job-interview">Technical Job Interview</option>
<option value="presentation">Product Presentation</option>
<option value="meeting">Team Meeting</option>
<option value="documentation">Technical Documentation Review</option>
</select>
</div>
<div id="scenario-description" class="bg-blue-50 p-4 rounded-lg mb-6">
<h3 class="font-bold text-gray-900 mb-2">Technical Job Interview</h3>
<p class="text-gray-700">You are being interviewed for a software engineering position. The interviewer asks you to explain your experience with API development.</p>
</div>
<button id="start-practice" class="w-full px-6 py-3 bg-blue-500 text-white font-medium rounded-lg hover:bg-blue-600 flex items-center justify-center">
<i data-feather="mic" class="mr-2"></i> Start Practice Session
</button>
</div>
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Your Response</h2>
<div id="waveform"></div>
<div class="flex justify-center mb-4">
<button id="record-btn" class="px-6 py-2 bg-red-500 text-white rounded-full hidden">
<i data-feather="mic" class="mr-2"></i> Recording...
</button>
<button id="stop-btn" class="px-6 py-2 bg-gray-200 text-gray-700 rounded-full hidden">
<i data-feather="square" class="mr-2"></i> Stop
</button>
</div>
<div class="speech-bubble hidden" id="user-response">
<p>Your recorded response will appear here...</p>
</div>
<div id="ai-feedback" class="mt-6 hidden">
<h3 class="font-bold text-gray-900 mb-2">AI Feedback</h3>
<div class="bg-gray-50 p-4 rounded-lg">
<div id="feedback-content" class="text-gray-700">
<p>Waiting for analysis...</p>
</div>
<div class="mt-4 flex items-center">
<i data-feather="star" class="text-yellow-400 mr-2"></i>
<span id="score" class="font-medium">Score: -</span>
</div>
</div>
</div>
</div>
</div>
<div class="mt-12 bg-white rounded-xl shadow-md p-8">
<h2 class="text-2xl font-bold text-gray-900 mb-6">Practice History</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Scenario</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Score</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Feedback</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">2023-11-15</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Technical Interview</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span class="px-2 py-1 bg-green-100 text-green-800 rounded-full">8.2/10</span>
</td>
<td class="px-6 py-4 text-sm text-gray-500">Good technical vocabulary but work on fluency</td>
</tr>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">2023-11-10</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Team Meeting</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span class="px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full">6.5/10</span>
</td>
<td class="px-6 py-4 text-sm text-gray-500">Clear points but need more natural transitions</td>
</tr>
</tbody>
</table>
</div>
</div>
</main>
<footer class="bg-gray-900 text-white py-12">
<div class="container mx-auto px-4">
<div class="grid md:grid-cols-4 gap-8 mb-8">
<div>
<h3 class="text-xl font-bold mb-4 flex items-center">
<i data-feather="mic" class="mr-2"></i> TechTalk Fluency
</h3>
<p class="text-gray-400">Master technical English for your professional success.</p>
</div>
<div>
<h4 class="font-bold mb-4">Resources</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">Technical Glossary</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Pronunciation Guide</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Business Email Templates</a></li>
</ul>
</div>
<div>
<h4 class="font-bold mb-4">Company</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">About Us</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Careers</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Contact</a></li>
</ul>
</div>
<div>
<h4 class="font-bold mb-4">Legal</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">Terms</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Privacy</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Cookies</a></li>
</ul>
</div>
</div>
<div class="border-t border-gray-800 pt-8 flex flex-col md:flex-row justify-between items-center">
<p class="text-gray-400 mb-4 md:mb-0">© 2023 TechTalk Fluency Factory. All rights reserved.</p>
<div class="flex space-x-6">
<a href="#" class="text-gray-400 hover:text-white"><i data-feather="twitter"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i data-feather="linkedin"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i data-feather="youtube"></i></a>
<a href="#" class="text-gray-400 hover:text-white"><i data-feather="instagram"></i></a>
</div>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/wavesurfer.js@7"></script>
<script>
feather.replace();
// Initialize WaveSurfer
const wavesurfer = WaveSurfer.create({
container: '#waveform',
waveColor: '#3b82f6',
progressColor: '#2563eb',
cursorColor: '#1d4ed8',
barWidth: 2,
barRadius: 3,
cursorWidth: 1,
height: 100,
barGap: 2
});
// Scenario descriptions
const scenarios = {
'job-interview': {
title: 'Technical Job Interview',
description: 'You are being interviewed for a software engineering position. The interviewer asks you to explain your experience with API development.'
},
'presentation': {
title: 'Product Presentation',
description: 'Present our new SaaS product to potential clients. Highlight key features and technical specifications.'
},
'meeting': {
title: 'Team Meeting',
description: 'Lead a discussion about the current sprint progress. Explain technical blockers and proposed solutions.'
},
'documentation': {
title: 'Technical Documentation Review',
description: 'Explain the key aspects of our API documentation to a new team member.'
}
};
// Scenario selector
document.getElementById('scenario-select').addEventListener('change', function() {
const scenario = scenarios[this.value];
document.querySelector('#scenario-description h3').textContent = scenario.title;
document.querySelector('#scenario-description p').textContent = scenario.description;
});
// Record button functionality
document.getElementById('start-practice').addEventListener('click', function() {
this.classList.add('hidden');
document.getElementById('record-btn').classList.remove('hidden');
// TODO: Implement recording functionality with Web Speech API
// Then analyze with Gemini API for feedback
});
// Mock AI feedback (in a real app, this would call the Gemini API)
function generateMockFeedback() {
const feedbacks = [
"Good use of technical vocabulary but work on your fluency and natural pauses.",
"Excellent explanation of complex concepts, but try to vary your sentence structure more.",
"Your pronunciation is clear, but you used some non-technical terms where jargon would be more appropriate."
];
const score = (Math.random() * 2 + 6).toFixed(1); // Random score between 6-8
return {
feedback: feedbacks[Math.floor(Math.random() * feedbacks.length)],
score: score
};
}
// Stop recording and show feedback
document.getElementById('stop-btn').addEventListener('click', function() {
const feedback = generateMockFeedback();
document.getElementById('user-response').classList.remove('hidden');
document.getElementById('ai-feedback').classList.remove('hidden');
document.getElementById('feedback-content').innerHTML = `<p>${feedback.feedback}</p>`;
document.getElementById('score').textContent = `Score: ${feedback.score}/10`;
// TODO: In a real app, this would send the audio to Gemini API for analysis
// and display the real feedback
});
</script>
</body>
</html>