[英]Extract Sound from translate.google.com
Bunenas tardes señores! Bunenas tardes señores!
For many years I extract sound from google.translate.com by Chrome DevTools and the Network tab.多年来,我通过 Chrome DevTools 和 Network 选项卡从 google.translate.com 中提取声音。 When click the sound button in the Network tab mp3 file appears.
单击网络选项卡中的声音按钮时会出现 mp3 文件。 I just click on it and download for further educational purposes.
我只需单击它并下载以用于进一步的教育目的。
Now (literally today) there only XHR type files with countless character sequences inside square brackets as like as strings in JS arrays.现在(字面意思是今天)只有 XHR 类型的文件,其中方括号内有无数字符序列,就像 JS 数组中的字符串一样。 And page itself is quite complicated.
页面本身相当复杂。
How to extract sound in new circumstance?新环境下如何提取声音?
Thank you.谢谢你。
xhr
request to batchexecute?rpcids...
it would be several kB, these kind of xhr
responses contains mp3 encoded in base64.xhr
请求来batchexecute?rpcids...
它将是几个 kB,这些xhr
响应包含以 base64 编码的 mp3。"[\"//NExAAR...VV\"]"
, purge this string from brackets and quiotes to get something like //NExAAR...VV
and save it ingo sound.base64
file."[\"//NExAAR...VV\"]"
的数组中,从方括号和引号中清除此字符串以获得类似//NExAAR...VV
并将其保存在sound.base64
文件中。sound.base64
into a mp3 file by this command:sound.base64
的文本解码为 mp3 文件:base64 -d sound.base64 > 1.mp3
mpg123 1.mp3
OR或者
Use https://soundoftext.com/ or test https://github.com/soimort/translate-shell#usage Audio Options.使用https://soundoftext.com/或测试https://github.com/soimort/translate-shell#usage音频选项。
UPD:升级版:
curl ... | grep -oP '\[\["wrb.fr","jQ1olc","\[\\"\K(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?' | base64 -d > /tmp/123.mp3
thanks for code to @alukardd.感谢@alukardd 的代码。
It is possible to make a right click on the request in the Chrome DevTools: Copy => copy as cURL.可以在 Chrome DevTools 中右键单击请求:复制 => 复制为 cURL。
thanks for information to @fjewo.感谢@fjewo 提供的信息。
A quick alternative - If you are on Mac OSx, you could also install SoundFlower and re-route the audio output to a DAW or just QuickTime player.一个快速的替代方案 - 如果您在 Mac OSx 上,您还可以安装 SoundFlower 并将音频输出重新路由到 DAW 或只是 QuickTime 播放器。
https://soundflower.en.softonic.com/mac https://soundflower.en.softonic.com/mac
php code doing this:执行此操作的 php 代码:
<?php
$lang = 'en';
$text = 'hello world';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://translate.google.com/_/TranslateWebserverUi/data/batchexecute',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'f.req=' . urlencode(json_encode([[['jQ1olc', '["' . $text . '","' . $lang . '",true,"null"]', '', 'generic']]]))
));
$response = curl_exec($curl);
curl_close($curl);
preg_match('#"(\/\/NE.*)"]"#', $response, $matches);
file_put_contents('/root/test.mp3', base64_decode($matches[1]));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.