iOS 13 TTS Crashes - Unable to find resource `lang'[kLanguage] - (AVSpeechSynthesisVoice, AVSpeechUtterance) - crash

We are seeing a weird crash probably related to TTS (Fatal Exception: std::logic_error: Unable to find resource `lang'[kLanguage]). It happens for me with different languages, so it seems there is some change in iOS 13. Maybe the TextToSpeech ressources are not loaded in time. Anybody any idea? Does anybody else see this crash or better know how to fix this?
let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
if voice.name == storedName {
synthVoice = voice
break
}
}
...
let utterance = AVSpeechUtterance(string: text)
utterance.voice = self.synthVoice
self.synthesizer.speak(utterance)
Error: Fatal Exception: std::logic_error: Unable to find resource `lang'[kLanguage].
Trace:
8 libc++abi.dylib 0x19c929304 std::__terminate(void (*)()) + 16
9 libc++abi.dylib 0x19c928c58 __cxa_get_exception_ptr + 30
10 libc++abi.dylib 0x19c928c18 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 122
11 SiriTTS 0x19f877894 VoiceConfig::report_error(unsigned int, VoiceConfig::IfMissing, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 960
12 SiriTTS 0x19f877d88 VoiceConfigImpl::get_json(unsigned int, VoiceConfig::IfMissing) const + 144
13 SiriTTS 0x19f8e1210 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > VoiceConfig::get_param<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(unsigned int, VoiceConfig::IfMissing) const + 36
14 SiriTTS 0x19f848490 NashvilleAdapterStream::NashvilleAdapterStream(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 308
15 SiriTTS 0x19f8c0158 std::__1::__compressed_pair_elem<NashvilleAdapterStream, 1, false>::__compressed_pair_elem<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&, 0ul, 1ul>(std::__1::piecewise_construct_t, std::__1::tuple<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>, std::__1::__tuple_indices<0ul, 1ul>) + 72
16 SiriTTS 0x19f8c00d0 std::__1::__shared_ptr_emplace<NashvilleAdapterStream, std::__1::allocator<NashvilleAdapterStream> >::__shared_ptr_emplace<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(std::__1::allocator<NashvilleAdapterStream>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 40
17 SiriTTS 0x19f8c0078 std::__1::shared_ptr<NashvilleAdapterStream> std::__1::shared_ptr<NashvilleAdapterStream>::make_shared<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 52
18 SiriTTS 0x19f8bffd8 std::__1::shared_ptr<Module> std::__1::__invoke_void_return_wrapper<std::__1::shared_ptr<Module> >::__call<void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool> >(void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&&&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&) + 48
19 SiriTTS 0x19f8bdeb4 ModuleFactory::ModuleFactoryImpl::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 164
20 SiriTTS 0x19f8bdda4 ModuleFactory::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 60
21 SiriTTS 0x19f8652e4 GryphonPipelineFactory::pipeline_from_config(std::__1::shared_ptr<SharedObjectPool>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&) + 472
22 SiriTTS 0x19f866a84
GryphonPipelineFactory::nashvilleFE_backend_pipeline(std::__1::shared_ptr<SharedObjectPool>) + 1140 23 SiriTTS 0x19f85ffb0 FeatureExtractorTarget::init_with_object_pool(std::__1::shared_ptr, bool) + 924
24 SiriTTS 0x19f86027c
FeatureExtractorTarget::init_with_install_path(char const*) + 272
25 TTSSpeechBundle 0x110480b50 (Missing)
26 TTSSpeechBundle 0x1104919c4 (Missing)
27 TTSSpeechBundle 0x110491a6c (Missing)
28 TTSSpeechBundle 0x11048ef44 (Missing)
29 TTSSpeechBundle 0x110490514 (Missing)
30 TTSSpeechBundle 0x11048eefc (Missing)
31 libsystem_pthread.dylib 0x19c8781f0 _pthread_start + 124
32 libsystem_pthread.dylib 0x19c87baf0 thread_start + 8

Related

How can I write enums with inline calculation of the powers?

I have once seen a beautifully and easy to follow enum.
It was written in such a way that one didn't have to calculate the powers by himself (1, 2, 4, 8, 16, 32, 64, 128, etc.), but instead, one could simply write like 1, 2, 3, 4, 5, etc.
The following is surely not correct, but you can get the flavor:
Public Enum eSomething
NotDefined = 0 ^ 2
Max = 1 ^ 2
Jeff = 2 ^ 2
Lisa = 3 ^ 2
Donald = 4 ^ 2
etc...
Does anybody know how to write it correctly?
Thank you very much!
Does this work for you?
Public Enum eSomething
NotDefined = CInt(2 ^ 0)
Max = CInt(2 ^ 1)
Jeff = CInt(2 ^ 2)
Lisa = CInt(2 ^ 3)
Donald = CInt(2 ^ 4)
End Enum
I have this enum that I find a convenient starting place...
<Flags()> Public Enum Bits As Long
none = 0
B00 = 1L << 0 ' 1
B01 = 1L << 1 ' 2
B02 = 1L << 2 ' 4
B03 = 1L << 3 ' 8
B04 = 1L << 4 ' 16
B05 = 1L << 5 ' 32
B06 = 1L << 6 ' 64
B07 = 1L << 7 ' 128
B08 = 1L << 8 ' 256
B09 = 1L << 9 ' 512
B10 = 1L << 10 ' 1,024
B11 = 1L << 11 ' 2,048
B12 = 1L << 12 ' 4,096
B13 = 1L << 13 ' 8,192
B14 = 1L << 14 ' 16,384
B15 = 1L << 15 ' 32,768
B16 = 1L << 16 ' 65,536
B17 = 1L << 17 ' 131,072
B18 = 1L << 18 ' 262,144
B19 = 1L << 19 ' 524,288
B20 = 1L << 20 ' 1,048,576
B21 = 1L << 21 ' 2,097,152
B22 = 1L << 22 ' 4,194,304
B23 = 1L << 23 ' 8,388,608
B24 = 1L << 24 ' 16,777,216
B25 = 1L << 25 ' 33,554,432
B26 = 1L << 26 ' 67,108,864
B27 = 1L << 27 ' 134,217,728
B28 = 1L << 28 ' 268,435,456
B29 = 1L << 29 ' 536,870,912
B30 = 1L << 30 ' 1,073,741,824
B31 = 1L << 31 ' 2,147,483,648
B32 = 1L << 32 ' 4,294,967,296
B33 = 1L << 33 ' 8,589,934,592
B34 = 1L << 34 ' 17,179,869,184
B35 = 1L << 35 ' 34,359,738,368
B36 = 1L << 36 ' 68,719,476,736
B37 = 1L << 37 ' 137,438,953,472
B38 = 1L << 38 ' 274,877,906,944
B39 = 1L << 39 ' 549,755,813,888
B40 = 1L << 40 ' 1,099,511,627,776
B41 = 1L << 41 ' 2,199,023,255,552
B42 = 1L << 42 ' 4,398,046,511,104
B43 = 1L << 43 ' 8,796,093,022,208
B44 = 1L << 44 ' 17,592,186,044,416
B45 = 1L << 45 ' 35,184,372,088,832
B46 = 1L << 46 ' 70,368,744,177,664
B47 = 1L << 47 ' 140,737,488,355,328
B48 = 1L << 48 ' 281,474,976,710,656
B49 = 1L << 49 ' 562,949,953,421,312
B50 = 1L << 50 ' 1,125,899,906,842,624
B51 = 1L << 51 ' 2,251,799,813,685,248
B52 = 1L << 52 ' 4,503,599,627,370,496
B53 = 1L << 53 ' 9,007,199,254,740,992
B54 = 1L << 54 ' 18,014,398,509,481,984
B55 = 1L << 55 ' 36,028,797,018,963,968
B56 = 1L << 56 ' 72,057,594,037,927,936
B57 = 1L << 57 ' 144,115,188,075,855,872
B58 = 1L << 58 ' 288,230,376,151,711,744
B59 = 1L << 59 ' 576,460,752,303,423,488
B60 = 1L << 60 ' 1,152,921,504,606,846,976
B61 = 1L << 61 ' 2,305,843,009,213,693,952
B62 = 1L << 62 ' 4,611,686,018,427,387,904
B63 = 1L << 63 ' -9,223,372,036,854,775,808
End Enum

How can I fix the damage in PDF files requested using MS2XML.XMLHTTP?

Friends, this is my first question here... I've been facing some problems when downloading a PDF buffer using MS2XML.XMLHTTP. I've been using Genexus to do so but I also tried right in pure Visual Fox Pro. The problem is that when I send the ResponseText to a string variable, some characters are replaced by question marks, the sam happens when I send the ResponseText to a pdf or txt file. The object created in MS2XML.XMLHTTP.6.0 does not allow using the ResponseBody property. Any thoughts on how could I solve it using MS2XML.XMLHTTP? Thanks.
oHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
oHTTP.Open("GET", 'https://homologacao.plugboleto.com.br/api/v1/boletos/impressa /lote/NIKLfYBWz',.F.)
oHTTP.setRequestHeader("content-type", "application/pdf")
oHTTP.Send()
? oHTTP.responseText
I've received someething like the following (full of question marks):
%PDF-1.4 %??2 0 obj <</ColorSpace/DeviceRGB/Subtype/Image/Height 38/Filter/DCTDecode/Type/XObject/Width 149/BitsPerComponent 8/Length 2619>>stream ???JFIF H H ??C  !"$"$??C?? & ?" ?? ??? } !1AQa"q2???#B??R?$3br? %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz???????????????????????????????????????????????????? ??? w !1AQaq"2?B????#3R??$4?&'()56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz??????????????????????????????????????????????????? ? ?h???8OO????a&??G?3? ?p1???|b?o?? ??x?_???%??E?en9??T???T>.????JG??rx??????????h?w????????:?!?????????jlm?Tn???????u??? ??Ey?PA?? (?? (?? (?? (??>B???;.??3?e??J??~?F??? y,s??i???#?m=kw???? ?[?K#????vR#G??^$?????k?[??BSu??#???M??????? _??Z?Fo??????/??*x?¾ mn??{)???80??s]W?x? ??+??k??=????????8 ?|D?c?j???h???$?8???:c??(???M/?Ze??;O?[?J????? '?~/j~!???n?urm???1^ITl;?3?%[?b??~?&<=u?Y\x??W6?¬$2?q?1?;??qc??_??qk>?&?v?????,??F?{??x???s??????{?k????r8.??<P?|,????q?]I?]?e???p;??/?W?x??)???A?????&)??dc,?d7?J?s??m?>???????!??9Va?? c???Zv??x+?b?wd??f?8a????????,6????????x?? ?-????<9F???????[~$?{??o???X??????y?ZgQ?#8??ox;? ???|??mZ?? I~a?k ~P ?? j??? '?c??4?F??l??$?8???(?'?"?.?????,????9V?????d???????UU)??? ???o?&???4?7?Z?? g???y?
W[?????d?Q$?#??^mZ???B Z(??QE ?Q#Q#Q#Q#Q#??endstream endobj 6 0 obj <</Filter/FlateDecode/Length 846>>stream x??V???+?q??z???'U./h???{???d?U??xf??PQ?O???unA???x1?0 50]#?\?T?y?B?s?9B? ? 2|????C???2t????k?U??]??]{? ?????s?AH??????h?"w????? f?????i??? ??>?9?8?#??"??G?$???<??0???S?2??sn?n??^?5?\FN?o1?4?~4~??Qe=&?T[???????Z??x??????k?????0z'#?;?'a??a?f~?q?~8ZH~?m???????Mm?p?#hh{????W7??????
?8?Olk'?A|?[???P?5?????uGxRr#?pw<$y?n??kD ???0??ih??9?5v??0?_}iG?Dq?8??_U??5a?????k????d???M??2???C(??;t2uA]z ??6A??o?t?}d????[?<;??R?iO8n??f???40???S?aVX????Y?p2N?eq]N?VeE?>??/V0?]MV?&???.aZ-???z2???????????8o??3?S????????gf??B?'6??]?J endstream endobj 8 0 obj<</Contents 6 0 R/Type/Page/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<</F1 3 0 R/F2 4 0 R>>/XObject<</Xf1 1 0 R/Xf2 5 0 R/img0 2 0 R>>>>/Parent 7 0 R/MediaBox[0 0 595 842]>>endobj 3 0 obj<</Subtype/Type1/Type/Font/BaseFont/Helvetica-Bold/Encoding/WinAnsiEncoding>>endobj 4 0 obj<</Subtype/Type1/Type/Font/BaseFont/Helvetica/Encoding/WinAnsiEncoding>>endobj 5 0 obj <</Subtype/Form/Filter/FlateDecode/Type/XObject/Matrix [1 0 0 1 0 0]/FormType 1/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]>>/BBox[0 0 292.41 39]/Length 474>>stream x?m??e1C?#???1Ly}??Ua??>????r?R?????r?7gr??a???\??PTj??p???s????~m"???:K??T???1????Gw({c???? !???p?rB g M?QG*?PC ?o??v?????'n[!n2??}*?g}r?G??J?R"aI?S??q ???d;??-??m?????y?lCp??[B(=?L??G[]2??)???
?8???9L????]y)?B??t<??E??????I????????#1?]$? ??h??6?Q[A)?8????<???????z??8c??????s??R????%6? endstream endobj 1 0 obj <</Subtype/Form/Filter/FlateDecode/Type/XObject/Matrix [1 0 0 1 0 0]/FormType 1/Resources<</ProcSet[/PDF/Text]/ExtGState 9 0 R/Font 10 0 R>>/Length 1818/BBox[0 0 595.28 419.53]>>stream x???Ko???t??V|???4-$n??{Pm%]6????P????:?$E?6i ?4??????d??m.U?7L????E??"???e?^r??c????????S#'?????????X?bz?k.J?3!?)??{?V ??'VS1?????8??L???? fU"&Fx?v?Q?9G??EL]?iLIN}?C?i~??4???J<??P?4Ec??F??P%c=!
?=?!U??P?T?b]???k>+¹&?5?9A5ai?"???G????H???J??J?#N??#?3dP??#O=A6%??&dO?eU&5;?Q?#M?'??.??8????P???z!
'??j??O?8??7?
?f????????u???^???:N#?q?Y?xN6Kjv B??Z?????<?? Dx^?J??;A1?3s /?S?k?8??'?9?n??.w?s????g????? M<0????????<?,p???xG!pv?v??O??,?!pv?v?P??l?O??3?M)[????????x??D?h????Z??&i)??,????k???k????j*???-?#?'?x9D)]?J:?=?G??1r? ???!???X?I???|n?q}?=?6?:ðl??????_T??[??_?AC???YI??????+??]??}f}S?P<{??EY??#??q?pah???,Pj?????v~??a?c???{R?7????? ?E~?mv??v?6??t ?? ??Y?????&???F?7P'?e?????R&??(?#????????)?2???P??j?.I??s4?|???s???$z????????E?P??x?{??tU?????????|??b?'?jH????f6 .?g? ?"?????iVR";;?P?'????F?????*??^?b?Nu6rO6? ?Xn[~>t???x2????n?[?D^????6C4O??vx??p?#???$?ru??Yj??55,?Z???u?&?yy????%????+????aMk?3 ???v?1M\A&?q???? '?Sf?,??ce)? ??x?????P?#?Ea&y????/n??~8j???????Co????????????%?? ????????5C???(?<??}???OA???a$?)J?`?!vd????T????D{,?}^?e?]]#?'#T?v??J??;??4?G?e???&b?Bl???K????.?t=s?i?;6.> ?????:?H??Z}:.V? ??) endstream endobj 9 0 obj<</R7 11 0 R/R9 12 0 R>>endobj 10 0 obj<</R8 13 0 R>>endobj 11 0 obj<</TK true/Type/ExtGState/BM/Normal/OPM 1>>endobj 12 0 obj<</Type/ExtGState/SA true>>endobj 13 0 obj<</Subtype/Type1/Type/Font/BaseFont/Helvetica/Encoding 14 0 R>>endobj 14 0 obj<</Type/Encoding/Differences[225/aacute/acircumflex/atilde 231/ccedilla 233/eacute/ecircumflex 243/oacute 245/otilde 250/uacute]>>endobj 7 0 obj<</Kids[8 0 R]/Type/Pages/Count 1>>endobj 15 0 obj<</Type/Catalog/Pages 7 0 R>>endobj 16 0 obj<<>>endobj xref 0 17 0000000000 65535 f 0000004765 00000 n 0000000015 00000 n 0000003908 00000 n 0000004000 00000 n 0000004087 00000 n 0000002787 00000 n 0000007190 00000 n 0000003700 00000 n 0000006794 00000 n 0000006833 00000 n 0000006863 00000 n 0000006922 00000 n 0000006965 00000 n 0000007044 00000 n 0000007240 00000 n 0000007285 00000 n trailer<</Info 16 0 R/ID []/Root 15 0 R/Size 17>>startxref 7305 %%EOF
Since a PDF is a binary file and not a text file, it is quite normal you would see ? and all sorts of other non-printable characters. Instead save it to a file on disk and open with something like ShellExecute. ie:
oHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
oHTTP.Open("GET", 'https://homologacao.plugboleto.com.br/api/v1/boletos/impressa /lote/NIKLfYBWz',.F.)
oHTTP.setRequestHeader("content-type", "application/pdf")
oHTTP.Send()
Local lcFileName
lcFileName = Forcepath(Sys(2015)+'.pdf', Sys(2023))
Strtofile(oHttp.responseText, m.lcFileName)
Declare Long ShellExecute In "shell32.dll" ;
long HWnd, String lpszOp, ;
string lpszFile, String lpszParams, ;
string lpszDir, Long nShowCmd
ShellExecute(_vfp.HWnd,'',m.lcFileName,'','',1)
EDIT: It was not a job MSXML2.XmlHttp. You simply download the file as a PDF and open it:
Local lcFileName, lcRemote
lcRemote = 'https://homologacao.plugboleto.com.br/api/v1/boletos/impressao/lote/NIKLfYBWz'
lcFileName = Forcepath(Sys(2015)+'.pdf', Sys(2023))
If (getFileFromURL(m.lcRemote, m.lcFileName) = 0)
Declare Long ShellExecute In "shell32.dll" ;
long HWnd, String lpszOp, ;
string lpszFile, String lpszParams, ;
string lpszDir, Long nShowCmd
ShellExecute(_vfp.HWnd,'',m.lcFileName,'','',1)
Endif
Procedure getFileFromURL
Lparameters tcRemoteFile,tcLocalFile
Declare Integer URLDownloadToFile In urlmon.Dll;
INTEGER pCaller, String szURL, String szFileName,;
INTEGER dwReserved, Integer lpfnCB
Return URLDownloadToFile(0, m.tcRemoteFile, m.tcLocalFile, 0, 0)
endproc

iOS 13 Text To Speech (TTS - AVSpeechSynthesisVoice) crashes for some users after update

We are seeing a weird crashes for a small percentage of users related to a problem of TTS after updating to iOS 13. Anybody any idea why this happens? Anybody seeing the same crashes?
let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
if voice.name == storedName {
synthVoice = voice
break
}
}
...
let utterance = AVSpeechUtterance(string: text)
utterance.voice = self.synthVoice
self.synthesizer.speak(utterance)
Crashlog:
Error: Fatal Exception: std::logic_error: Unable to find resource `lang'[kLanguage].
8 libc++abi.dylib 0x19c929304 std::__terminate(void (*)()) + 16
9 libc++abi.dylib 0x19c928c58 __cxa_get_exception_ptr + 30
10 libc++abi.dylib 0x19c928c18 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 122
11 SiriTTS 0x19f877894 VoiceConfig::report_error(unsigned int, VoiceConfig::IfMissing, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 960
12 SiriTTS 0x19f877d88 VoiceConfigImpl::get_json(unsigned int, VoiceConfig::IfMissing) const + 144
13 SiriTTS 0x19f8e1210 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > VoiceConfig::get_param<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(unsigned int, VoiceConfig::IfMissing) const + 36
14 SiriTTS 0x19f848490 NashvilleAdapterStream::NashvilleAdapterStream(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 308
15 SiriTTS 0x19f8c0158 std::__1::__compressed_pair_elem<NashvilleAdapterStream, 1, false>::__compressed_pair_elem<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&, 0ul, 1ul>(std::__1::piecewise_construct_t, std::__1::tuple<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>, std::__1::__tuple_indices<0ul, 1ul>) + 72
16 SiriTTS 0x19f8c00d0 std::__1::__shared_ptr_emplace<NashvilleAdapterStream, std::__1::allocator<NashvilleAdapterStream> >::__shared_ptr_emplace<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(std::__1::allocator<NashvilleAdapterStream>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 40
17 SiriTTS 0x19f8c0078 std::__1::shared_ptr<NashvilleAdapterStream> std::__1::shared_ptr<NashvilleAdapterStream>::make_shared<nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>&>(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&&) + 52
18 SiriTTS 0x19f8bffd8 std::__1::shared_ptr<Module> std::__1::__invoke_void_return_wrapper<std::__1::shared_ptr<Module> >::__call<void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool> >(void ModuleFactory::ModuleFactoryImpl::register_module<NashvilleAdapterStream>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::'lambda'(nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>)&&&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&&&, std::__1::shared_ptr<SharedObjectPool>&&) + 48
19 SiriTTS 0x19f8bdeb4 ModuleFactory::ModuleFactoryImpl::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 164
20 SiriTTS 0x19f8bdda4 ModuleFactory::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&, std::__1::shared_ptr<SharedObjectPool>) + 60
21 SiriTTS 0x19f8652e4 GryphonPipelineFactory::pipeline_from_config(std::__1::shared_ptr<SharedObjectPool>, nlohmann::basic_json<std::__1::map, std::__1::vector, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, long long, unsigned long long, double, std::__1::allocator, nlohmann::adl_serializer> const&) + 472
22 SiriTTS 0x19f866a84
GryphonPipelineFactory::nashvilleFE_backend_pipeline(std::__1::shared_ptr<SharedObjectPool>) + 1140 23 SiriTTS 0x19f85ffb0 FeatureExtractorTarget::init_with_object_pool(std::__1::shared_ptr, bool) + 924
24 SiriTTS 0x19f86027c
FeatureExtractorTarget::init_with_install_path(char const*) + 272
25 TTSSpeechBundle 0x110480b50 (Missing)
26 TTSSpeechBundle 0x1104919c4 (Missing)
27 TTSSpeechBundle 0x110491a6c (Missing)
28 TTSSpeechBundle 0x11048ef44 (Missing)
29 TTSSpeechBundle 0x110490514 (Missing)
30 TTSSpeechBundle 0x11048eefc (Missing)
31 libsystem_pthread.dylib 0x19c8781f0 _pthread_start + 124
32 libsystem_pthread.dylib 0x19c87baf0 thread_start + 8
UPDATE: Issue appears to be fixed in iOS 13.2! Yay!
Looks like a bug on some devices running IOS 13 (In my case 13.1.2 on an iPhone SE),
AVSpeechSynthesisVoice.speechVoices()
is returning nil.
Also, FYI, setting a voice using the AVSpeechSynthesisVoice initializer such as
AVSpeechSynthesisVoice(language: "fr-FR")
results in the voice being set as nil and English being used as a fallback/default.
I have filed a feedback on both issues... and also previously this one which was fixed during 13 beta, but now I'm not so sure... since this new issue either supersedes it or is a result of engineers in different departments working at cross-purposes.

Assign a string to CommandText in IL using Reflexil

I need to edit a query for an application developed some time ago. But I don't have the source code, only the compiled dll's. Following is the source decompiled by Telerik JustDecompile.
conCl.Conn();
conCl.Con.Open();
SqlCommand com = conCl.Com;
string[] strArrays = new string[] { "SELECT * FROM TBL_USER WHERE u_name = '", user.Replace("'", "''"), "' AND u_pass = '", password.Replace("'", "''"), "' and u_IsActive = 1 " };
com.CommandText = string.Concat(strArrays);
SqlDataReader sqlDataReader = conCl.Com.ExecuteReader();
The resulting IL in Reflexil is:
off op operand
set code
18 ldfld System.Data.SqlClient.SqlConnection ANZFrameWorkDAL.ConCls::Con
23 callvirt System.Void System.Data.SqlClient.SqlConnection::Open()
28 nop
29 ldloc.0
30 ldfld System.Data.SqlClient.SqlCommand ANZFrameWorkDAL.ConCls::Com
35 ldc.i4.5
36 newarr System.String
41 stloc.s -> (4) (System.String[])
43 ldloc.s -> (4) (System.String[])
45 ldc.i4.0
46 ldstr SELECT * FROM TBL_USER WHERE u_name = '
51 stelem.ref
52 nop
53 ldloc.s -> (4) (System.String[])
55 ldc.i4.1
56 ldarg.1
57 ldstr '
62 ldstr ''
67 callvirt System.String System.String::Replace(System.String,System.String)
72 stelem.ref
73 nop
74 ldloc.s -> (4) (System.String[])
76 ldc.i4.2
77 ldstr ' AND u_pass = '
82 stelem.ref
83 nop
84 ldloc.s -> (4) (System.String[])
86 ldc.i4.3
87 ldarg.2
88 ldstr '
93 ldstr ''
98 callvirt System.String System.String::Replace(System.String,System.String)
103 stelem.ref
104 nop
105 ldloc.s -> (4) (System.String[])
107 ldc.i4.4
108 ldstr ' and u_IsActive = 1
113 stelem.ref
114 nop
115 ldloc.s -> (4) (System.String[])
117 call System.String System.String::Concat(System.String[])
122 callvirt System.Void System.Data.SqlClient.SqlCommand::set_CommandText(System.String)
127 nop
128 ldloc.0
129 ldfld System.Data.SqlClient.SqlCommand ANZFrameWorkDAL.ConCls::Com
134 callvirt System.Data.SqlClient.SqlDataReader System.Data.SqlClient.SqlCommand::ExecuteReader()
Now what I want is:
com.CommandText = "Select * form tbl_user where u_name = 'admin'"
I tried to load a string after offset 115 as
opcode = ldstr operand = select * form tbl_user where u_name = 'admin'
but the output became
strArrays.CommandText = string.Concat((string[])"select * form tbl_user where u_name = 'admin'");
so i deleted my change and add the same string after offset 117 as:
opcode = ldstr operand = select * form tbl_user where u_name = 'admin'
the output changed and feels somewhat near to what I want but still not correct. the output became:
string.Concat(strArrays).CommandText = "select * form tbl_user where u_name = 'admin'";
What I want is:
com.CommandText = "select * from tbl_user where u_name = 'admin'"
I also tried to add callvirt opcode after offset 122 but i was unable to find set_CommandText method in System.Data.SqlClient.SqlCommand when the loaded .NET framework was 4.6.1
How can I do this? Please, any help would be appreciated. THANKS
Most of the method is just the string concatenation so you can remove it. You can replace all the instructions from offset 35 to 117 inclusive, with a single ldstr that contains your string.

Base64 Encoding for file upload VB.Net

I have a project in VBA that does the base64 encoding and uploads the file (.xlsm).
VBA Code:
Option Explicit
Private Const clOneMask = 16515072 '000000 111111 111111 111111
Private Const clTwoMask = 258048 '111111 000000 111111 111111
Private Const clThreeMask = 4032 '111111 111111 000000 111111
Private Const clFourMask = 63 '111111 111111 111111 000000
Private Const clHighMask = 16711680 '11111111 00000000 00000000
Private Const clMidMask = 65280 '00000000 11111111 00000000
Private Const clLowMask = 255 '00000000 00000000 11111111
Private Const cl2Exp18 = 262144 '2 to the 18th power
Private Const cl2Exp12 = 4096 '2 to the 12th
Private Const cl2Exp6 = 64 '2 to the 6th
Private Const cl2Exp8 = 256 '2 to the 8th
Private Const cl2Exp16 = 65536 '2 to the 16th
Private cbTransTo(63) As Byte
Private cbTransFrom(255) As Byte
Private clPowers8(255) As Long
Private clPowers16(255) As Long
Private clPowers6(63) As Long
Private clPowers12(63) As Long
Private clPowers18(63) As Long
Private Sub Class_Initialize()
Dim lTemp As Long
For lTemp = 0 To 63 'Fill the translation table.
Select Case lTemp
Case 0 To 25
cbTransTo(lTemp) = 65 + lTemp 'A - Z
Case 26 To 51
cbTransTo(lTemp) = 71 + lTemp 'a - z
Case 52 To 61
cbTransTo(lTemp) = lTemp - 4 '1 - 0
Case 62
cbTransTo(lTemp) = 43 'Chr(43) = "+"
Case 63
cbTransTo(lTemp) = 47 'Chr(47) = "/"
End Select
Next lTemp
For lTemp = 0 To 255 'Fill the lookup tables.
clPowers8(lTemp) = lTemp * cl2Exp8
clPowers16(lTemp) = lTemp * cl2Exp16
Next lTemp
For lTemp = 0 To 63
clPowers6(lTemp) = lTemp * cl2Exp6
clPowers12(lTemp) = lTemp * cl2Exp12
clPowers18(lTemp) = lTemp * cl2Exp18
Next lTemp
For lTemp = 0 To 255 'Fill the translation table.
Select Case lTemp
Case 65 To 90
cbTransFrom(lTemp) = lTemp - 65 'A - Z
Case 97 To 122
cbTransFrom(lTemp) = lTemp - 71 'a - z
Case 48 To 57
cbTransFrom(lTemp) = lTemp + 4 '1 - 0
Case 43
cbTransFrom(lTemp) = 62 'Chr(43) = "+"
Case 47
cbTransFrom(lTemp) = 63 'Chr(47) = "/"
End Select
Next lTemp
End Sub
Public Function Encode(sString As String) As String
Dim bTrans(63) As Byte, bOut() As Byte, bIn() As Byte, lOutSize As Long
Dim lChar As Long, lTrip As Long, iPad As Integer, lLen As Long, lTemp As Long, lPos As Long
iPad = Len(sString) Mod 3 'See if the length is divisible by 3
If iPad Then 'If not, figure out the end pad and resize the input.
iPad = 3 - iPad
sString = sString & String(iPad, Chr(0))
End If
bIn = StrConv(sString, vbFromUnicode) 'Load the input string.
lLen = ((UBound(bIn) + 1) \ 3) * 4 'Length of resulting string.
lTemp = lLen \ 72 'Added space for vbCrLfs.
lOutSize = ((lTemp * 2) + lLen) - 1 'Calculate the size of the output buffer.
ReDim bOut(lOutSize) 'Make the output buffer.
lLen = 0 'Reusing this one, so reset it.
For lChar = LBound(bIn) To UBound(bIn) Step 3
lTrip = clPowers16(bIn(lChar)) + clPowers8(bIn(lChar + 1)) + bIn(lChar + 2) 'Combine the 3 bytes
lTemp = lTrip And clOneMask 'Mask for the first 6 bits
bOut(lPos) = cbTransTo(lTemp \ cl2Exp18) 'Shift it down to the low 6 bits and get the value
lTemp = lTrip And clTwoMask 'Mask for the second set.
bOut(lPos + 1) = cbTransTo(lTemp \ cl2Exp12) 'Shift it down and translate.
lTemp = lTrip And clThreeMask 'Mask for the third set.
bOut(lPos + 2) = cbTransTo(lTemp \ cl2Exp6) 'Shift it down and translate.
bOut(lPos + 3) = cbTransTo(lTrip And clFourMask) 'Mask for the low set.
If lLen = 68 Then 'Ready for a newline
bOut(lPos + 4) = 13 'Chr(13) = vbCr
bOut(lPos + 5) = 10 'Chr(10) = vbLf
lLen = 0 'Reset the counter
lPos = lPos + 6
Else
lLen = lLen + 4
lPos = lPos + 4
End If
Next lChar
If bOut(lOutSize) = 10 Then lOutSize = lOutSize - 2 'Shift the padding chars down if it ends with CrLf.
If iPad = 1 Then 'Add the padding chars if any.
bOut(lOutSize) = 61 'Chr(61) = "="
ElseIf iPad = 2 Then
bOut(lOutSize) = 61
bOut(lOutSize - 1) = 61
End If
Encode = StrConv(bOut, vbUnicode) 'Convert back to a string and return it.
End Function
The generated output is exactly like this:
Required Output
I am trying to achieve the same output in VB.Net but I am unable to do so. I tried using the following:
Dim testStr As String = "test.xlsm"
Dim byt As Byte() = Encoding.Default.GetBytes(testStr)
testStr = Convert.ToBase64String(byt)
Input String: http://txt.do/obff
But I am not getting exactly the same string back. The first line is different in both cases (VBA and VB.Net) and I'm not sure why.
Required Output (VBA and the weblink):
UEsDBBQABgAIAAAAIQCsmTVRbwEAAD8EAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAA
Generated Output (VB.Net):
UEsDBBQABgAIAAAAIQA/PzVRbwEAAD8EAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCA/BAIoPwACAAAAAAAAAAAAAAAAAAAAAAAAA
Could you please let me know where I am going wrong and how can I achieve the same in VB.Net?
I managed to solve the problem by getting the file directly, reading all its bytes and converting it to base64 string.
Dim dat As Byte() = IO.File.ReadAllBytes(FileName)
testStr = Convert.ToBase64String(dat, Base64FormattingOptions.InsertLineBreaks)