| 220 | logging.error(f"{music_fn} does not exist.") |
| 221 | |
| 222 | def get_args(): |
| 223 | parser = argparse.ArgumentParser(description='Run inference with your model') |
| 224 | parser.add_argument('-m', '--model_name', default="InspireMusic-1.5B-Long", help='Model name') |
| 225 | |
| 226 | parser.add_argument('-d', '--model_dir', help='Model folder path') |
| 227 | |
| 228 | parser.add_argument('-t', '--text', default="Experience soothing and sensual instrumental jazz with a touch of Bossa Nova, perfect for a relaxing restaurant or spa ambiance.", help='Prompt text') |
| 229 | |
| 230 | parser.add_argument('-a', '--audio_prompt', default=None, help='Prompt audio') |
| 231 | |
| 232 | parser.add_argument('-c', '--chorus', default="intro", help='Chorus tag generation mode (e.g., random, verse, chorus, intro, outro)') |
| 233 | |
| 234 | parser.add_argument('-f', '--fast', type=bool, default=False, help='Enable fast inference mode (without flow matching)') |
| 235 | |
| 236 | parser.add_argument('-g', '--gpu', type=int, default=1, help='GPU ID for this rank, -1 for CPU') |
| 237 | |
| 238 | parser.add_argument('--task', default='text-to-music', choices=['text-to-music', 'continuation', 'reconstruct', 'super_resolution'], help='Inference task type: text-to-music, continuation, reconstruct, super_resolution') |
| 239 | |
| 240 | parser.add_argument('-r', '--result_dir', default="exp/inspiremusic", help='Directory to save generated audio') |
| 241 | |
| 242 | parser.add_argument('-o', '--output_fn', default="output_audio", help='Output file name') |
| 243 | |
| 244 | parser.add_argument('--format', type=str, default="wav", choices=["wav", "mp3", "m4a", "flac"], help='Format of output audio') |
| 245 | |
| 246 | parser.add_argument('--sample_rate', type=int, default=24000, help='Sampling rate of input audio') |
| 247 | |
| 248 | parser.add_argument('--output_sample_rate', type=int, default=48000, choices=[24000, 48000], help='Sampling rate of generated output audio') |
| 249 | |
| 250 | parser.add_argument('-s', '--time_start', type=float, default=0.0, help='Start time in seconds') |
| 251 | |
| 252 | parser.add_argument('-e', '--time_end', type=float, default=30.0, help='End time in seconds') |
| 253 | |
| 254 | parser.add_argument('--max_audio_prompt_length', type=float, default=5.0, help='Maximum audio prompt length in seconds') |
| 255 | |
| 256 | parser.add_argument('--min_generate_audio_seconds', type=float, default=10.0, help='Minimum generated audio length in seconds') |
| 257 | |
| 258 | parser.add_argument('--max_generate_audio_seconds', type=float, default=30.0, help='Maximum generated audio length in seconds') |
| 259 | |
| 260 | parser.add_argument('--fp16', type=bool, default=True, help='Inference with fp16 model') |
| 261 | |
| 262 | parser.add_argument('--fade_out', type=bool, default=True, help='Apply fade out effect to generated audio') |
| 263 | |
| 264 | parser.add_argument('--fade_out_duration', type=float, default=1.0, help='Fade out duration in seconds') |
| 265 | |
| 266 | parser.add_argument('--trim', type=bool, default=False, help='Trim the silence ending of generated audio') |
| 267 | |
| 268 | args = parser.parse_args() |
| 269 | |
| 270 | if not args.model_dir: |
| 271 | args.model_dir = os.path.join("../../pretrained_models", args.model_name) |
| 272 | |
| 273 | print(args) |
| 274 | return args |
| 275 | def main(): |
| 276 | env_variables() |
| 277 | args = get_args() |