( task, text="", audio=None, model_name="InspireMusic-Base", chorus="intro", output_sample_rate=48000, max_generate_audio_seconds=30.0, time_start = 0.0, time_end=30.0, trim=False)
| 51 | return hash_string |
| 52 | |
| 53 | def get_args( |
| 54 | task, text="", audio=None, model_name="InspireMusic-Base", |
| 55 | chorus="intro", |
| 56 | output_sample_rate=48000, max_generate_audio_seconds=30.0, time_start = 0.0, time_end=30.0, trim=False): |
| 57 | |
| 58 | if "24kHz" in model_name: |
| 59 | output_sample_rate = 24000 |
| 60 | |
| 61 | if output_sample_rate == 24000: |
| 62 | fast = True |
| 63 | else: |
| 64 | fast = False |
| 65 | # This function constructs the arguments required for InspireMusic |
| 66 | args = { |
| 67 | "task" : task, |
| 68 | "text" : text, |
| 69 | "audio_prompt" : audio, |
| 70 | "model_name" : model_name, |
| 71 | "chorus" : chorus, |
| 72 | "fast" : fast, |
| 73 | "fade_out" : True, |
| 74 | "trim" : trim, |
| 75 | "output_sample_rate" : output_sample_rate, |
| 76 | "min_generate_audio_seconds": 10.0, |
| 77 | "max_generate_audio_seconds": max_generate_audio_seconds, |
| 78 | "max_audio_prompt_length": 5.0, |
| 79 | "model_dir" : os.path.join("pretrained_models", |
| 80 | model_name), |
| 81 | "result_dir" : OUTPUT_AUDIO_DIR, |
| 82 | "output_fn" : generate_filename(), |
| 83 | "format" : "wav", |
| 84 | "time_start" : time_start, |
| 85 | "time_end": time_end, |
| 86 | "fade_out_duration": 1.0, |
| 87 | } |
| 88 | |
| 89 | if args["time_start"] is None: |
| 90 | args["time_start"] = 0.0 |
| 91 | args["time_end"] = args["time_start"] + args["max_generate_audio_seconds"] |
| 92 | |
| 93 | print(args) |
| 94 | return args |
| 95 | |
| 96 | |
| 97 | def trim_audio(audio_file, cut_seconds=5): |
no test coverage detected