apps-sdk 1.0.182 → 1.0.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.182",
3
+ "version": "1.0.184",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,7 @@
29
29
  "expo-speech": "~13.0.1",
30
30
  "expo-store-review": "~8.0.1",
31
31
  "expo-tracking-transparency": "~5.1.1",
32
+ "franc-min": "^6.2.0",
32
33
  "mixpanel-react-native": "^3.0.8",
33
34
  "react-native": "0.76.6",
34
35
  "react-native-adjust": "^5.0.2",
@@ -1,6 +1,8 @@
1
+ import * as config from '../../config';
1
2
  import Voice from '@react-native-voice/voice';
2
3
  import Session from "./Session";
3
4
  import * as Speech from 'expo-speech';
5
+ import { franc } from 'franc-min';
4
6
 
5
7
  class VoiceService {
6
8
  constructor() {
@@ -61,14 +63,30 @@ class VoiceService {
61
63
  }
62
64
 
63
65
  speak(message, language = null, voice = null, onStart, onDone, onError) {
64
- const deviceLanguage = Session.getDeviceLanguageAndRegion();
66
+ let detectedLanguageCode = 'en_US';
67
+ try {
68
+ detectedLanguageCode = franc(message);
69
+ } catch (error) {
70
+ detectedLanguageCode = 'eng';
71
+ console.error('Error detecting language:', error);
72
+ }
73
+
74
+ const languageMap = {
75
+ 'eng': 'en_US',
76
+ 'spa': 'es_ES',
77
+ 'fra': 'fr_FR',
78
+ 'ita': 'it_IT',
79
+ 'por': 'pt_PT',
80
+ 'deu': 'de_DE',
81
+ };
65
82
 
66
- const finalLanguage = language || deviceLanguage;
67
- const finalVoice = voice || `${deviceLanguage}-language`;
83
+ const detectedLanguage = languageMap[detectedLanguageCode] || 'en_US';
84
+ const finalLanguage = detectedLanguage || Session.getDeviceLanguageAndRegion();
85
+ const finalVoice = voice || `${finalLanguage}-voice`;
86
+ config.DEBUG_MODE && console.log('Speech detected language:', detectedLanguage, 'final language:', finalLanguage, 'final voice:', finalVoice);
68
87
 
69
88
  Speech.speak(message, {
70
89
  language: finalLanguage,
71
- voice: finalVoice,
72
90
  rate: 1,
73
91
  pitch: 1,
74
92
  onStart: () => {