Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
ade460f9
Unverified
Commit
ade460f9
authored
Feb 05, 2022
by
Wolle
Committed by
GitHub
Feb 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add m4a atom 'isom'
parent
d23a2471
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
4 deletions
+51
-4
src/Audio.cpp
src/Audio.cpp
+51
-4
No files found.
src/Audio.cpp
View file @
ade460f9
...
...
@@ -712,8 +712,51 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path) {
}
//---------------------------------------------------------------------------------------------------------------------
bool
Audio
::
connecttospeech
(
const
char
*
speech
,
const
char
*
lang
){
log_e
(
"GoogleTTS is no longer available due to restrictions"
);
return
false
;
setDefaults
();
char
host
[]
=
"translate.google.com.vn"
;
char
path
[]
=
"/translate_tts"
;
uint16_t
speechLen
=
strlen
(
speech
);
uint16_t
speechBuffLen
=
speechLen
+
300
;
memcpy
(
m_lastHost
,
speech
,
256
);
char
*
speechBuff
=
(
char
*
)
malloc
(
speechBuffLen
);
if
(
!
speechBuff
)
{
log_e
(
"out of memory"
);
return
false
;}
memcpy
(
speechBuff
,
speech
,
speechLen
);
speechBuff
[
speechLen
]
=
'\0'
;
urlencode
(
speechBuff
,
speechBuffLen
);
char
resp
[
strlen
(
speechBuff
)
+
200
]
=
""
;
strcat
(
resp
,
"GET "
);
strcat
(
resp
,
path
);
strcat
(
resp
,
"?ie=UTF-8&tl="
);
strcat
(
resp
,
lang
);
strcat
(
resp
,
"&client=tw-ob&q="
);
strcat
(
resp
,
speechBuff
);
strcat
(
resp
,
" HTTP/1.1
\r\n
"
);
strcat
(
resp
,
"Host: "
);
strcat
(
resp
,
host
);
strcat
(
resp
,
"
\r\n
"
);
strcat
(
resp
,
"User-Agent: Mozilla/5.0
\r\n
"
);
strcat
(
resp
,
"Accept-Encoding: identity
\r\n
"
);
strcat
(
resp
,
"Accept: text/html
\r\n
"
);
strcat
(
resp
,
"Connection: close
\r\n\r\n
"
);
free
(
speechBuff
);
_client
=
static_cast
<
WiFiClient
*>
(
&
client
);
if
(
!
_client
->
connect
(
host
,
80
))
{
log_e
(
"Connection failed"
);
return
false
;
}
_client
->
print
(
resp
);
m_f_webstream
=
true
;
m_f_running
=
true
;
m_f_ssl
=
false
;
m_f_tts
=
true
;
setDatamode
(
AUDIO_HEADER
);
return
true
;
}
//---------------------------------------------------------------------------------------------------------------------
void
Audio
::
urlencode
(
char
*
buff
,
uint16_t
buffLen
,
bool
spacesOnly
)
{
...
...
@@ -1587,11 +1630,15 @@ int Audio::read_M4A_Header(uint8_t *data, size_t len) {
stopSong
();
return
-
1
;
}
if
(
specialIndexOf
(
data
,
"M4A "
,
20
)
!=
8
)
{
log_e
(
"subtype 'MA4 ' expected, but found '%s '"
,
(
data
+
8
));
int
m4a
=
specialIndexOf
(
data
,
"M4A "
,
20
);
int
isom
=
specialIndexOf
(
data
,
"isom"
,
20
);
if
((
m4a
!=
8
)
&&
(
isom
!=
8
)){
log_e
(
"subtype 'MA4 ' or 'isom' expected, but found '%s '"
,
(
data
+
8
));
stopSong
();
return
-
1
;
}
m_controlCounter
=
M4A_CHK
;
retvalue
=
atomsize
;
headerSize
=
atomsize
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment