简体   繁体   English

从 translate.google.com 提取声音

[英]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?新环境下如何提取声音?

  • Some how extract from XHR files.一些如何从 XHR 文件中提取的方法。
  • May be some way to record in GNU/Linux sound system.可能是在 GNU/Linux 声音系统中录制的某种方式。
  • Or something else.或者是其他东西。

Thank you.谢谢你。

How to extract sound from translate.google.com Base64 response.如何从 translate.google.com Base64 响应中提取声音。

  1. Visit translate.google.com, run Chrome DevTools by F12 key, enter the Network tab.访问 translate.google.com,按 F12 键运行 Chrome DevTools,进入 Network 标签。 Enter a text and press enter to make sound button appears.输入文本,然后按 Enter 以显示声音按钮。 Click the sound button.单击声音按钮。
  2. Select a largest 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。
  3. At the Response tab of this request would be a long string in an array surrounded by square brackets and escaped double quotes "[\"//NExAAR...VV\"]" , purge this string from brackets and quiotes to get something like //NExAAR...VV and save it ingo sound.base64 file.在此请求的 Response 选项卡上,将是一个长字符串,包含在方括号和转义双引号"[\"//NExAAR...VV\"]"的数组中,从方括号和引号中清除此字符串以获得类似//NExAAR...VV并将其保存在sound.base64文件中。
  4. Then decode text from sound.base64 into a mp3 file by this command:然后通过以下命令将sound.base64的文本解码为 mp3 文件:
base64 -d sound.base64 > 1.mp3
  1. To listen mp3 from the terminal next command may be used:要从终端收听 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.

相关问题 如何在 Chrome 中禁用来自 HTML 的谷歌翻译 - How to disable Google translate from HTML in Chrome 是否可以从 Chrome 扩展程序触发 Google Chrome 浏览器翻译功能? - Is it possible to trigger Google Chrome browser translate function from Chrome extension? 插件:强制谷歌翻译翻译注入的文本 - plugin : force google translate to translate injected text 内容安全政策…translation.googleapis.com? - Content Security Policy… translate.googleapis.com? 将Google翻译结果导出为CSV吗? - Export Google Translate results as CSV? Google Chrome浏览器的Android浏览器中的翻译语言菜单控件的名称是什么,以及如何实现? - What is the name of translate language menu control from Google Chrome's Android browser and how to implement it? 隐式 select 通过谷歌翻译翻译页面的语言 - Implicitly select the language to translate page via Google Translate 有没有一种方法可以使用谷歌翻译来翻译纯文本和 markdown 的内容? - Is there a method to use Google Translate to translate content with both plain text and markdown? Google.com和DOMContentLoaded - Google.com and DOMContentLoaded 从浏览器捕获系统声音 - Capture system sound from browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM