Thanks to visit codestin.com
Credit goes to github.com

Skip to content

llama-tts : add -o option #12042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 0 commits into from
Closed

Conversation

marcoStocchi
Copy link
Contributor

  • enabled optional cmdline argument '-o' on tts to specify an output filename. It defaults to 'output.wav'.

  • program now returns ENOENT in case of file write failure

common/arg.cpp Outdated
@@ -1858,13 +1858,15 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
? params.lora_outfile.c_str()
: ex == LLAMA_EXAMPLE_CVECTOR_GENERATOR
? params.cvector_outfile.c_str()
: params.out_file.c_str()),
: ex == LLAMA_EXAMPLE_TTS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's now time to convert this block into if..else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngxson Hi, could you pls have a look a the changes see if they are ok ? MAny thanks..

@ngxson ngxson changed the title llama-tts llama-tts : add -o option Mar 7, 2025
@ngxson ngxson requested a review from ggerganov March 7, 2025 22:00
common/common.h Outdated
Comment on lines 414 to 416
std::string
lora_outfile = "ggml-lora-merged-f16.gguf",
ttss_outfile = "output.wav";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string
lora_outfile = "ggml-lora-merged-f16.gguf",
ttss_outfile = "output.wav";
std::string lora_outfile = "ggml-lora-merged-f16.gguf";
std::string ttss_outfile = "output.wav";

@@ -963,11 +964,18 @@ lovely<|t_0.56|><|code_start|><|634|><|596|><|1766|><|1556|><|1306|><|1285|><|14
LOG_INF("%s: time for spectral ops: %.3f ms\n", __func__, (ggml_time_us() - t_spec_start) / 1000.0f);
LOG_INF("%s: total time: %.3f ms\n", __func__, (ggml_time_us() - t_main_start) / 1000.0f);

save_wav16(fname, audio, n_sr);
int retval(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int retval(0);
int retval = 0;

Comment on lines 971 to 1081
}

else {
retval=ENOENT;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else {
retval=ENOENT;
} else {
retval = ENOENT;

common/arg.cpp Outdated

// retrieving the right default output filename,
// depending on the example program...
std::string * out_file_ptr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string * out_file_ptr;
const char * default_out_file;

And also change the rest to match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngxson thank you, all changes done and committed on this PR.

marcoStocchi added a commit to marcoStocchi/llama.cpp that referenced this pull request Mar 8, 2025
* arg.cpp : refactored default output fname if/else block

* codestyle alignments in this PR (ggml-org#12042)
common/arg.cpp Outdated
Comment on lines 1873 to 1881
if (ex == LLAMA_EXAMPLE_EXPORT_LORA)
default_out_file = params.lora_outfile.c_str();
else if (ex == LLAMA_EXAMPLE_CVECTOR_GENERATOR)
default_out_file = params.cvector_outfile.c_str();
else if (ex == LLAMA_EXAMPLE_TTS)
default_out_file = params.ttss_outfile.c_str();
else // currently coded as "imatrix.dat", see common.h
default_out_file = params.out_file.c_str();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ex == LLAMA_EXAMPLE_EXPORT_LORA)
default_out_file = params.lora_outfile.c_str();
else if (ex == LLAMA_EXAMPLE_CVECTOR_GENERATOR)
default_out_file = params.cvector_outfile.c_str();
else if (ex == LLAMA_EXAMPLE_TTS)
default_out_file = params.ttss_outfile.c_str();
else // currently coded as "imatrix.dat", see common.h
default_out_file = params.out_file.c_str();
if (ex == LLAMA_EXAMPLE_EXPORT_LORA) {
default_out_file = params.lora_outfile.c_str();
} else if (ex == LLAMA_EXAMPLE_CVECTOR_GENERATOR) {
default_out_file = params.cvector_outfile.c_str();
} else if (ex == LLAMA_EXAMPLE_TTS) {
default_out_file = params.ttss_outfile.c_str();
} else // currently coded as "imatrix.dat", see common.h
default_out_file = params.out_file.c_str();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, committed.

common/common.h Outdated
std::string lora_outfile = "ggml-lora-merged-f16.gguf";
std::string ttss_outfile = "output.wav";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be simpler to just have a single std::string outfile; parameter that is used by all examples to output things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I see that this requires some changes also in cvector-generator and export-lora. If ok for you I refactor this, perhaps with a dedicated PR ?

if (save_wav16(params.out_file, audio, n_sr)) {
LOG_INF("%s: audio written to file '%s'\n", __func__, params.out_file.c_str());
} else {
retval=ENOENT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
retval=ENOENT;
retval = ENOENT;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, committed.

marcoStocchi added a commit to marcoStocchi/llama.cpp that referenced this pull request Mar 9, 2025
As discussed in PR 'llama-tts : add -o option' (ggml-org#12042):

* common_params : 'out_file' string is the only output file name parameter left in common_params. It's intended to be used in all example programs implementing an '-o' option.

* cvector-generator, export-lora, imatrix : default output filenames moved from 'common_params' to the 'main()' of each example program.
ggerganov pushed a commit that referenced this pull request Mar 10, 2025
As discussed in PR 'llama-tts : add -o option' (#12042):

* common_params : 'out_file' string is the only output file name parameter left in common_params. It's intended to be used in all example programs implementing an '-o' option.

* cvector-generator, export-lora, imatrix : default output filenames moved from 'common_params' to the 'main()' of each example program.
@marcoStocchi
Copy link
Contributor Author

@ggerganov Good morning, thank you for approving/merging the PR 'Refactoring -o option' (#12278). After the merge, many of the commits of this PR are obsolete. Is it ok for you if I open a new PR for implementing the '-o' on llama-tts?

@ngxson
Copy link
Collaborator

ngxson commented Mar 12, 2025

Yes you can either open a new PR or fix commit using git merge master locally

jpohhhh pushed a commit to Telosnex/llama.cpp that referenced this pull request Mar 14, 2025
As discussed in PR 'llama-tts : add -o option' (ggml-org#12042):

* common_params : 'out_file' string is the only output file name parameter left in common_params. It's intended to be used in all example programs implementing an '-o' option.

* cvector-generator, export-lora, imatrix : default output filenames moved from 'common_params' to the 'main()' of each example program.
marcoStocchi added a commit to marcoStocchi/llama.cpp that referenced this pull request Mar 15, 2025
* added -o option to specify an output file name

* llama-tts returns ENOENT in case of file write error

note : PR ggml-org#12042 is closed as superseded with this one.
ngxson pushed a commit that referenced this pull request Mar 15, 2025
* added -o option to specify an output file name

* llama-tts returns ENOENT in case of file write error

note : PR #12042 is closed as superseded with this one.
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Mar 19, 2025
As discussed in PR 'llama-tts : add -o option' (ggml-org#12042):

* common_params : 'out_file' string is the only output file name parameter left in common_params. It's intended to be used in all example programs implementing an '-o' option.

* cvector-generator, export-lora, imatrix : default output filenames moved from 'common_params' to the 'main()' of each example program.
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Mar 19, 2025
* added -o option to specify an output file name

* llama-tts returns ENOENT in case of file write error

note : PR ggml-org#12042 is closed as superseded with this one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants