download_file_with_aria2c
Browse files
    	
        App/Generate/database/DescriptAPI.py
    CHANGED
    
    | @@ -157,8 +157,12 @@ class Speak: | |
| 157 |  | 
| 158 | 
             
                    return save_path
         | 
| 159 |  | 
| 160 | 
            -
                async def download_file_with_aria2c( | 
| 161 | 
            -
                     | 
|  | |
|  | |
|  | |
|  | |
| 162 | 
             
                    process = await asyncio.create_subprocess_shell(
         | 
| 163 | 
             
                        command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
         | 
| 164 | 
             
                    )
         | 
| @@ -166,10 +170,10 @@ class Speak: | |
| 166 | 
             
                    stdout, stderr = await process.communicate()
         | 
| 167 |  | 
| 168 | 
             
                    if process.returncode == 0:
         | 
| 169 | 
            -
                        print(f"File downloaded successfully to { | 
| 170 | 
             
                    else:
         | 
| 171 | 
             
                        print(f"Failed to download file. Error: {stderr.decode()}")
         | 
| 172 | 
            -
                    return  | 
| 173 |  | 
| 174 |  | 
| 175 | 
             
            async def process_narrations(narrations):
         | 
|  | |
| 157 |  | 
| 158 | 
             
                    return save_path
         | 
| 159 |  | 
| 160 | 
            +
                async def download_file_with_aria2c(self, url):
         | 
| 161 | 
            +
                    filename = str(uuid.uuid4()) + ".wav"
         | 
| 162 | 
            +
                    os.makedirs(self.dir, exist_ok=True)
         | 
| 163 | 
            +
                    save_path = os.path.join(self.dir, filename)
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                    command = f"aria2c {url} -o {save_path}"
         | 
| 166 | 
             
                    process = await asyncio.create_subprocess_shell(
         | 
| 167 | 
             
                        command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
         | 
| 168 | 
             
                    )
         | 
|  | |
| 170 | 
             
                    stdout, stderr = await process.communicate()
         | 
| 171 |  | 
| 172 | 
             
                    if process.returncode == 0:
         | 
| 173 | 
            +
                        print(f"File downloaded successfully to {save_path}")
         | 
| 174 | 
             
                    else:
         | 
| 175 | 
             
                        print(f"Failed to download file. Error: {stderr.decode()}")
         | 
| 176 | 
            +
                    return save_path
         | 
| 177 |  | 
| 178 |  | 
| 179 | 
             
            async def process_narrations(narrations):
         |