leaonline / easy-speech

🔊 Cross browser Speech Synthesis also known as Text to speech or TTS; no dependencies; uses Web Speech API

Home Page:https://leaonline.github.io/easy-speech/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Max Length for Text to read in some voices?

stereonom opened this issue · comments

I recognized that (even in your demo), that the Google Voices (e.g. Google UK English Male) can't read very long text.

When I truncate my text to 4053 charactes it works. With 4054 it doesn't.

Here's the text: (4054 characters long. To make it work, just remove one character)

How forward-thinking marketing leaders are setting the course for growth 600+ senior marketers shared their take on the state of marketing today. We’ve distilled their insights here. Deep dive into emerging trends shaping the market and consumer behavior, and the strategies set to leverage them for growth. Uncover how AI and machine learning can play into marketing, the importance of prescriptive analytics and data-driven decision-making, how consumers’ drive towards sustainability interacts with brand purpose, and when to prioritize long-term vs short-term investments. Reasons to be cheerful: marketing’s emerging optimism in the face of adversity Macroeconomic and geopolitical risks continue to present a challenging scenario for businesses. But emerging technologies, diverse revenue streams and changes in consumer behavior all present opportunities for positive change. GfK’s new research shows that 78% of CMOs are optimistic about the future. And progressive, forward-thinking marketing leaders have every reason to be upbeat. Leading-edge technology is elevating the function’s customer-facing and back-office operations. Real-time insights and prescriptive data analytics are gaining traction. Investment in AI and related innovative technology is growing as use cases proliferate. And as ESG concerns move to the forefront of board discussions, CMOs have a chance to become champions of the consumer-critical sustainability agenda. Each holds importance in the boardroom and offers CMOs a platform to increase their strategic influence. Indeed, they have a unique opportunity to position themselves ever closer to the heart of their organization and instigate positive change. “I see a massive correlation among CMOs that embrace technology and those that are optimists,” says Gonzalo Garcia Villanueva, global CMO at NielsenIQ. “We’re also seeing companies better understand the need to strategically invest in their brand for long-term growth – and this extends to sustainability too. Purpose and the bottom-line are converging and this is a positive for marketers.” 78% of senior marketers say they are optimistic about the future Optimism across markets Certain sectors continue to prove their resilience despite ongoing economic uncertainty. The technology and durables market is representative of a new post-Covid, digital buying cycle, likewise the retail sector. Both are bouncing back as consumers look to make purchases postponed during the pandemic. “Consumers are making more time to evaluate what they spend their money on,” reports one senior marketing leader at L’Oréal. “This is an opportunity for ecommerce because it enables consumers to survey their spending. As a brand, we have a duty to ensure that they have all the information they need.” Market leaders have adjusted by investing in digital-first activations and campaigns. This strategy builds closer connections with consumers in the virtual arenas they increasingly inhabit. It also offers better customer experiences that deliver long-term value. These can be further optimized through data insights and generative AI that underpin greater personalization and automation. “Marketers are increasingly leading the charge towards data maturity, becoming ever more sophisticated in how data is used,” says Gonzalo Garcia Villanueva, global CMO at NielsenIQ. “Advanced data capabilities that help organizations make better decisions to prepare for whatever comes next will be a key marker of success in the future.” CMOs that can make the business case for adopting analytics and more innovative technology - and then make the most of it - will be in an enviable position. Those that can’t, will find themselves trapped in a cycle of reactive, short-term activity that erodes their margins and brand value over time. Advanced data capabilities that help organizations make better decisions to prepare for whatever comes next will be a key marker of success in the future. Most marketers show impressive confidence in their ability to justify marketing investment

Is this a known thing?
It there any variable I can check to get this max length?

Hi @stereonom thanks for reporting. I assume you used Chrome? Which OS did you use?

Usually there has been a fix for that already: https://github.com/jankapunkt/easy-speech/blob/master/src/EasySpeech.js#L695 This is indeed an issue of it's own and not covered yet.

Let me investigate this

@jankapunkt yeah, I'm using Chrome – on MacOS. It's not a bug that only happens in the current versions. I'm seeing this since I started using easy-speech. (~July 2023)

I tested some other text and the maximum seems to vary a bit. My other test text worked with 4005 characters but failed with 4006. 🤷🏼‍♂️

@stereonom can you please paste/analyze the other texts with the code below? I have a strong assumption that the text exceeds 4096 bytes, which is what I get when analyzing the text above:

const text = '...' // the text from above
console.debug((new TextEncoder().encode(text)).length) // 4097

In JavaScript not every character is the same size: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#utf-16_characters_unicode_code_points_and_grapheme_clusters

I therefore assume, that all Google Voices have an upper limit of 4096 bytes of length. Please confirm this with your other texts.

If this is the case we can at least throw an error message if

  • the current utterance is a google voice
  • text exceeds 4096 bytes of length

I would like to avoid for now to automatically split the text and read the chunks as this will lead to multiple start/end events being fired. I'd rather leave this to the user as they might know much better where to split, how long the pause between the chunks etc. is best.

What do you think?

Yeah, u are right. My other text is 4.097 bytes long. 🤪

I understand that you will not include the auto-splitting because of the events.
Perhaps it could be an option that is not enabled by default. So if it exceeds the limit, the error message could say it's to long and the developer should consider turning auto-splitting on with a link to some FAQ this problem with the events is descriibed.
If not, an example would be great how to implement such feature.
I think finding the rough point where to split. Then find the last dot or exclamation/question mark and do the split.

@stereonom would you mind reviewing (using the GitHub review functionality) this pull request: #229