Skip to content

Commit 6d52bcd

Browse files
committed
fix(ServiceContainer): Properly catch errors with text synthesis
1 parent c71a8ba commit 6d52bcd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/components/ServiceContainer/ServiceContainer.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ export const ServiceContainer = () => {
2424
setError(createError(TOKEN_ERROR_TITLE, authJson));
2525
}
2626

27-
try {
28-
synthesize({
29-
accessToken: authJson.accessToken,
30-
element: audioElementRef.current,
31-
text,
32-
voice: voice.id,
33-
});
34-
} catch (error) {
35-
setError(createError(SYNTHESIZE_ERROR_TITLE, error));
36-
}
27+
const audio = await synthesize({
28+
accessToken: authJson.accessToken,
29+
autoPlay: false,
30+
element: audioElementRef.current,
31+
text,
32+
voice: voice.id,
33+
});
34+
audio.play().catch(error => {
35+
console.log('ERROR', error);
36+
setError(createError(SYNTHESIZE_ERROR_TITLE, error.message));
37+
});
3738
};
3839

3940
return (

0 commit comments

Comments
 (0)