PHP calls Google Translate_tts API implementation code _php

Source: Internet
Author: User
Keywords Google translate_tts api
Today with Google Translate, found a good thing: Google Translate_tts, call this API can hear English pronunciation,
Saves yourself the hassle of uploading audio files.
I used PHP to write a call method, you can save the audio file locally.
As follows:
Copy the Code code as follows:
$newfname = ' 1.wmv ';
$reqBaseURL = ' Http://translate.google.com/translate_tts?tl=en&q=how%20do%20you%20do ';
$remote _file = fopen ($reqBaseURL, "RB");
if ($remote _file) {
$NEWF = fopen ($newfname, "WB");
if ($NEWF) {
while (!feof ($remote _file)) {
Fwrite ($NEWF, Fread ($remote _file, 1024 * 8), 1024 * 8);
}
}
}
if ($remote _file) {
Fclose ($remote _file);
}
if ($NEWF) {
Fclose ($NEWF);
}
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.