2k1
  • Home
  • Programming
  • System
  • Design
  • Applications
  • Tech
No Result
View All Result
  • Login
2k1
  • Home
  • Programming
  • System
  • Design
  • Applications
  • Tech
No Result
View All Result
2k1
No Result
View All Result

Chuyển văn bản thành âm thanh tiếng việt

Nguyen Pham by Nguyen Pham
01/08/2020
in Programming, Python
Reading Time: 1 min read
A A
0

code

import requests
import re
import time
def mp3file(strin):
    while True:
        while True:
            Header = {
                'Accept': '*/*',
                'Accept-Encoding': 'gzip, deflate, br',
                'Accept-Language': 'vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7,fr-FR;q=0.6,fr;q=0.5',
                'Connection': 'keep-alive',
                'Content-Length': '187',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'Host': 'speech.openfpt.vn',
                'Origin': 'https://fpt.ai',
                'Referer': 'https://fpt.ai/vi/tts-vi',
                'Sec-Fetch-Dest': 'empty',
                'Sec-Fetch-Mode': 'cors',
                'Sec-Fetch-Site': 'cross-site',
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36',
            }
            data = {
                'voice-type': 'new',
                'text': strin,
                'gender': 'myan',
                'speed': '0',
            }
            a = requests.post('https://speech.openfpt.vn/speech', data=data, headers=Header)
            try:
                res = re.search(r'"Url":"(.*?)"', a.text)
            except:
                continue
            try:
                urlmp3 = str(res.group(1))
            except:
                continue
            break
        print(urlmp3)
        mp3 = requests.get(urlmp3)
        print(mp3.status_code)
        if (mp3.status_code == 200):
            f = open(strin + '.mp3', 'wb')
            f.write(mp3.content)
            f.close()
            print("*******************")
            break
        else:
            mp3file(strin)
            break
#srcsub=open('subsrc.txt','r',encoding='UTF-8')
#listsub=srcsub.read().split('\n')
# while True:
#     mp3file(listsub[i])
#     i=i+1
#     if(i==len(listsub)):
#         break
#     print("..........Continue.........")

# for i in listsub:
#     if(len(i)==0):
#         continue
#     print(i)
#     mp3file(str(i))
while True:
    a=input("moi ban nhap chuoi: ")
    mp3file(a)
    

Previous Post

Các thông số cơ bản của hosting

Next Post

Luminar 3 – Luminar 2018 & Aurora HDR 2018

Related Posts

Xây dựng todo app với smartcontract
Go

Giới thiệu về đa luồng trong ngôn ngữ lập trình go có code minh họa.

by Nguyen Pham
29/06/2023
Programming

Lập trình rust cơ bản – vòng lặp

by Nguyen Pham
22/12/2022
Programming

Lập trình python cơ bản – Hello world

by Nguyen Pham
16/11/2022
Programming

Lập trình go cơ bản – Hello world

by Nguyen Pham
04/12/2022
Programming

Lập trình rust cơ bản – Biến

by Nguyen Pham
16/11/2022
Programming

Lập trình rust cơ bản – hello world

by Nguyen Pham
14/11/2022
Load More
Next Post

Luminar 3 - Luminar 2018 & Aurora HDR 2018

Please login to join discussion
Stock

Phân tích mã cổ phiếu VCB

by Nguyen Pham
26/04/2025
0

Phân tích mã cổ phiếu VCB (Ngân hàng TMCP Ngoại thương Việt Nam - Vietcombank) 1. Tổng quan về Vietcombank...

Read more

Facebook, Instagram bất ngờ sập trên diện rộng, liên tục đăng xuất người dùng!

05/03/2024
Xây dựng todo app với smartcontract

Web3 là gì?

30/06/2023
Xây dựng todo app với smartcontract

Giới thiệu về đa luồng trong ngôn ngữ lập trình go có code minh họa.

29/06/2023

Chạy ứng dụng react native đầu tiên của bạn

29/06/2023

@2021 2k1.org [email protected]

No Result
View All Result
  • Home
  • Review
  • Applications
  • Computers
  • Gaming
  • Microsoft

© 2021 NData

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In