from aip import AipSpeech
import pyttsx3
import os

"""新建一个ApiSpeech"""
APP_ID = '25477358'
API_KEY = '<KEY>'
SECRET_KEY = '<KEY>'

client = AipSpeech(APP_ID,API_KEY,SECRET_KEY)


def speaker(text):
    result = client.synthesis(text,'zh',1,{
            'vol':5,
            'spd':1,
            'piy':7,
            'per':4,
        })
    if not isinstance(result,dict):
        with open('result.mp3','wb') as f:
            f.write(result)
    engine = pyttsx3.init()
    engine.say 
    """ os.remove('result.mp3') """

from aip import AipSpeech
import pyttsx3
import os

"""新建一个ApiSpeech"""
APP_ID = '25477358'
API_KEY = '<KEY>'
SECRET_KEY = '<KEY>'

client = AipSpeech(APP_ID,API_KEY,SECRET_KEY)


def speaker(text):
    result = client.synthesis(text,'zh',1,{
            'vol':5,
            'spd':1,
            'piy':7,
            'per':4,
        })
    if not isinstance(result,dict):
        with open('result.mp3','wb') as f:
            f.write(result)
    engine = pyttsx3.init()
    engine.say 
    """ os.remove('result.mp3') """

新建一个ApiSpeech os.remove('result.mp3')