mirror of
https://github.com/Tony0410/News-reader-pro.git
synced 2026-05-24 21:31:44 +08:00
Major feature update: Enhanced RSS, voice fixes, dark mode, and UI improvements
## New Features - Article Summary Mode: AI-generated 30-second summaries with complexity analysis - Reading Stats Dashboard: Track articles read, listening time, and streaks - Bookmark/Resume: Auto-save progress when pausing, resume from where you left off - Audio Export: Export articles as downloadable WAV files - RSS Feed Manager: Subscribe to feeds with real-time validation and 31+ recommendations - Smart Speed: Auto-adjust playback based on article complexity - Voice Moods: Quick presets for different listening scenarios ## RSS Enhancements - Expanded recommendations from 8 to 31 sources across 5 categories: * General News (9 sources) * Technology (8 sources) * Business & Finance (5 sources) * Science & Research (5 sources) * International News (4 sources) - Real-time URL validation with visual feedback - Detailed error messages for different failure scenarios - Always-visible categorized recommendations - Auto-loading articles when feeds are added ## Bug Fixes - Fixed voice selection: Selected voice now consistently applies to playback - Implemented voice generation counter to prevent voice mixing between paragraphs - Fixed speed control to snap to clean 0.5 increments (1.0, 1.5, 2.0, etc.) - Fixed dark mode toggle by configuring Tailwind CDN for class-based dark mode - Removed vibe visualizer animation ## UI/UX Improvements - Redesigned voice selector with prominent voice panel and preview functionality - Added voice cards with emojis and descriptions - Enhanced feature toolbar with quick access to all new features - Improved reader view with better typography and reading modes - Added ambient reading modes (clean, sepia, night light) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -211,6 +211,87 @@ export const extractArticleContent = async (url: string): Promise<{ title: strin
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a 30-second summary of an article.
|
||||
*/
|
||||
export const generateArticleSummary = async (text: string, title: string): Promise<string> => {
|
||||
const ai = getAiClient();
|
||||
|
||||
const prompt = `
|
||||
You are a professional news summarizer. Create a brief, engaging summary of the following article.
|
||||
|
||||
TITLE: ${title}
|
||||
|
||||
ARTICLE TEXT:
|
||||
${text.substring(0, 8000)} ${text.length > 8000 ? '...[truncated]' : ''}
|
||||
|
||||
RULES:
|
||||
1. Create a summary that can be read aloud in about 30 seconds (approximately 80-100 words)
|
||||
2. Start with the most important/newsworthy point
|
||||
3. Include 2-3 key facts or takeaways
|
||||
4. Use clear, conversational language suitable for audio
|
||||
5. Do NOT use bullet points or formatting - write in flowing sentences
|
||||
6. End with a brief mention of why this matters
|
||||
|
||||
Output ONLY the summary text, nothing else.
|
||||
`;
|
||||
|
||||
const response = await ai.models.generateContent({
|
||||
model: 'gemini-2.5-flash',
|
||||
contents: prompt,
|
||||
config: {
|
||||
temperature: 0.3,
|
||||
}
|
||||
});
|
||||
|
||||
return response.text?.trim() || "Unable to generate summary.";
|
||||
};
|
||||
|
||||
/**
|
||||
* Analyzes text complexity for Smart Speed feature.
|
||||
*/
|
||||
export const analyzeTextComplexity = (text: string): {
|
||||
complexity: 'simple' | 'moderate' | 'complex';
|
||||
wordCount: number;
|
||||
estimatedReadTime: number;
|
||||
} => {
|
||||
const words = text.split(/\s+/).filter(w => w.length > 0);
|
||||
const wordCount = words.length;
|
||||
|
||||
// Calculate average word length
|
||||
const avgWordLength = words.reduce((sum, w) => sum + w.length, 0) / wordCount;
|
||||
|
||||
// Count sentences (rough estimate)
|
||||
const sentences = text.split(/[.!?]+/).filter(s => s.trim().length > 0).length;
|
||||
const avgSentenceLength = wordCount / Math.max(1, sentences);
|
||||
|
||||
// Count complex indicators
|
||||
const complexWords = words.filter(w => w.length > 10).length;
|
||||
const complexWordRatio = complexWords / wordCount;
|
||||
|
||||
// Score complexity (0-100)
|
||||
let score = 0;
|
||||
score += Math.min(30, avgWordLength * 4); // Longer words = more complex
|
||||
score += Math.min(30, avgSentenceLength * 1.5); // Longer sentences = more complex
|
||||
score += Math.min(40, complexWordRatio * 200); // More complex words = more complex
|
||||
|
||||
// Determine complexity level
|
||||
let complexity: 'simple' | 'moderate' | 'complex';
|
||||
if (score < 35) {
|
||||
complexity = 'simple';
|
||||
} else if (score < 55) {
|
||||
complexity = 'moderate';
|
||||
} else {
|
||||
complexity = 'complex';
|
||||
}
|
||||
|
||||
// Estimate read time (words per minute varies by complexity)
|
||||
const wpm = complexity === 'simple' ? 180 : complexity === 'moderate' ? 150 : 130;
|
||||
const estimatedReadTime = Math.ceil(wordCount / wpm);
|
||||
|
||||
return { complexity, wordCount, estimatedReadTime };
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates speech audio from text.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user