Skip to content

Commit

Permalink
🔀 Merge pull request #1558 from jovotech/v4/dev
Browse files Browse the repository at this point in the history
🔖 Prepare latest release
  • Loading branch information
jankoenig authored May 31, 2023
2 parents 48f9d3e + f5e6fdf commit 9a04f2b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
10 changes: 8 additions & 2 deletions clients/client-web/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,16 @@ The configuration for the [`SpeechSynthesizer`](https://github.com/jovotech/jovo
speechSynthesizer: {
enabled: true,
language: 'en',
voice: SpeechSynthesisVoice
voice: SpeechSynthesisVoice,
rate: number,
pitch: number
},
```

- `language`: Can also be overridden using the `locale` property in the root of the [client configuration](#configuration).
- `voice`: Learn more in the [official documentation by Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisVoice).
- `rate`: Learn more in the [official documentation by Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/rate).
- `pitch`: Learn more in the [official documentation by Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance/pitch).

The player has the following features:

Expand Down Expand Up @@ -447,10 +451,12 @@ Reprompts are played by the [`RepromptProcessor`](https://github.com/jovotech/jo
reprompts: {
enabled: true,
maxAttempts: 1,
resetSessionOnRepromptLimit: true
},
```

The `maxAttempts` property defines how many reprompts should be played before closing the session.
- `maxAttempts` property defines how many reprompts should be played before closing the session.
- `resetSessionOnRepromptLimit` property determines if the current session will be closed after the the maximum number of reprompts has been played. The default is `true`.

## Deployment

Expand Down
9 changes: 6 additions & 3 deletions clients/client-web/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
VoidListener,
} from './index';
import { EventListenerMap, TypedEventEmitter } from './utilities/TypedEventEmitter';
import { Output } from '../../../framework/dist/types';

export type ClientRequest = PlainObjectType<CoreRequest>;
export type ClientResponse = PlainObjectType<CoreResponse>;
Expand Down Expand Up @@ -183,8 +184,10 @@ export class Client extends TypedEventEmitter<ClientEventListenerMap> {
});

this.on(ClientEvent.RepromptLimitReached, () => {
this.store.resetSession();
this.store.save();
if(this.repromptProcessor.config.resetSessionOnRepromptLimit) {
this.store.resetSession();
this.store.save();
}
});

this.on(ClientEvent.Input, async (input) => {
Expand Down Expand Up @@ -303,4 +306,4 @@ export class Client extends TypedEventEmitter<ClientEventListenerMap> {
): RecordingStrategy<TYPE, any> | undefined {
return this.recordingStrategies.find((recordingStrategy) => recordingStrategy.type === type);
}
}
}
2 changes: 2 additions & 0 deletions clients/client-web/src/core/RepromptProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RecordingModality } from './RecordingStrategy';
export interface RepromptHandlerConfig {
enabled: boolean;
maxAttempts: number;
resetSessionOnRepromptLimit: boolean;
}

export type RepromptType = NormalizedOutputTemplate['reprompt'];
Expand All @@ -18,6 +19,7 @@ export class RepromptProcessor {
return {
enabled: true,
maxAttempts: 1,
resetSessionOnRepromptLimit: true,
};
}

Expand Down
8 changes: 8 additions & 0 deletions clients/client-web/src/standalone/SpeechSynthesizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface SpeechSynthesizerConfig {
enabled: boolean;
language: string;
voice?: SpeechSynthesisVoice;
rate?: number;
pitch?: number;
}

export class SpeechSynthesizer extends TypedEventEmitter<SpeechSynthesizerEventListenerMap> {
Expand Down Expand Up @@ -110,6 +112,12 @@ export class SpeechSynthesizer extends TypedEventEmitter<SpeechSynthesizerEventL
if (this.config.voice) {
utterance.voice = this.config.voice;
}
if (this.config.rate) {
utterance.rate = this.config.rate;
}
if (this.config.pitch !== undefined) {
utterance.pitch = this.config.pitch;
}

utterance.onerror = (e) => {
this.isSpeakingUtterance = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ export abstract class DashbotAnalyticsPlugin {
await axios.post(url, data);
} catch (error) {
if (error.isAxiosError) {
let message: string;
if (Array.isArray(error.response.data.errors)) {
message = error.response.data.errors.join('\n');
} else if (typeof error.response.data === 'string') {
message = error.response.data;
} else {
message = JSON.stringify(error.response.data);
}

throw new JovoError({
message: `Request to Dashbot failed: ${error.response.data.errors.join('\n')}`,
message: `Request to Dashbot failed: ${message}`,
});
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a04f2b

Please sign in to comment.