* Pick a reading duration in milliseconds based on the length of the text.
(text: string)
| 297 | * Pick a reading duration in milliseconds based on the length of the text. |
| 298 | */ |
| 299 | function generateDuration(text: string) { |
| 300 | const words = text.split(/\s+/).length; |
| 301 | const wordsPerMinute = 200; |
| 302 | const minutes = words / wordsPerMinute; |
| 303 | const duration = minutes * 60 * 1000; |
| 304 | return Math.max(duration, 4000); |
| 305 | } |