Text to Speach return 400 Request contains an invalid argument.
Im face that problem both of your python module and your web page that web page --> https://cloud.google.com/text-to-speech if im send that text to your api on that web page
rams phosphorus (16 percent) - 3 milligrams niacin (15 percent) - 0.3 milligram vitamin B6 (14 percent) - 0.2 milligram thiamine (12 perecent) - 0.2 miligram copper (10 percent) - 1.2 milligrams zinc (8 percent) - 0.6 milligrams pantothenic acid (6 percent) - 0.8 milligram iron (5 percent) - 7.9 micrograms folate (2 percent) - 19.5 milligrams calcium (2 percent) - 83.9 milligrams potassium (2 percent) Brown Rice vs. Black Rice vs. White Rice When it comes to white rice vs brown rice, brown rice nutrition definitely wins since brown rice gets polished (stripped of its nutrients) to become white rice. Unless white rice is enriched, it really doesnt offer the consumer much of anything in terms of nutrients so white rice nutrition is basically nonexistent. However, the less popular black rice aka forbidden rice is actually even more impressive than brown rice nutrition, but it does contain a lot more calories for the same serving. Heres how the different types of rice differ in terms of nutrient content when we compare a 100-gram cooking serving of each kind: - Brown rice: 111 calories, 3 grams protein, 2 grams fiber, 0.4 milligrams iron - White rice: 130 calories, 2 grams protein, 0 grams fiber, o.2 milligrams iron -
it's return me 400 invalid arguement i cant resolve reason of that response i guess its kind of bug ? if im mistake some think coul you explain me what is wrong on that text ?
Hi @nto4,
Please share more information about the specific code that is failing.
I wasn't able to produce the issue with the python sample here. See below where I ran the sample code with the text provided.
python3 synthesize_text.py --text "rams phosphorus (16 percent) - 3 milligrams niacin (15 percent) - 0.3 milligram vitamin B6 (14 percent) - 0.2 milligram thiamine (12 perecent) - 0.2 miligram copper (10 percent) - 1.2 milligrams zinc (8 percent) - 0.6 milligrams pantothenic acid (6 percent) - 0.8 milligram iron (5 percent) - 7.9 micrograms folate (2 percent) - 19.5 milligrams calcium (2 percent) - 83.9 milligrams potassium (2 percent) Brown Rice vs. Black Rice vs. White Rice When it comes to white rice vs brown rice, brown rice nutrition definitely wins since brown rice gets polished (stripped of its nutrients) to become white rice. Unless white rice is enriched, it really doesnt offer the consumer much of anything in terms of nutrients so white rice nutrition is basically nonexistent. However, the less popular black rice aka forbidden rice is actually even more impressive than brown rice nutrition, but it does contain a lot more calories for the same serving. Heres how the different types of rice differ in terms of nutrient content when we compare a 100-gram cooking serving of each kind: - Brown rice: 111 calories, 3 grams protein, 2 grams fiber, 0.4 milligrams iron - White rice: 130 calories, 2 grams protein, 0 grams fiber, o.2 milligrams iron -"
Audio content written to file "output.mp3"
The demo located at https://cloud.google.com/text-to-speech appears to get stuck with the text that you provided. I've filed an internal issue at b/264747534.
Regarding the specific 400 error that your received, there is usually some additional detail along with that error code that can be helpful for troubleshooting. As a start, try using the Try this method section on this page to experiment with text and parameters needed for a successful response.
For example, I had success with the following request body.
{
"audioConfig": {
"audioEncoding": "MP3"
},
"input": {
"text": "rams phosphorus (16 percent) - 3 milligrams niacin (15 percent) - 0.3 milligram vitamin B6 (14 percent) - 0.2 milligram thiamine (12 perecent) - 0.2 miligram copper (10 percent) - 1.2 milligrams zinc (8 percent) - 0.6 milligrams pantothenic acid (6 percent) - 0.8 milligram iron (5 percent) - 7.9 micrograms folate (2 percent) - 19.5 milligrams calcium (2 percent) - 83.9 milligrams potassium (2 percent) Brown Rice vs. Black Rice vs. White Rice When it comes to white rice vs brown rice, brown rice nutrition definitely wins since brown rice gets polished (stripped of its nutrients) to become white rice. Unless white rice is enriched, it really doesnt offer the consumer much of anything in terms of nutrients so white rice nutrition is basically nonexistent. However, the less popular black rice aka forbidden rice is actually even more impressive than brown rice nutrition, but it does contain a lot more calories for the same serving. Heres how the different types of rice differ in terms of nutrient content when we compare a 100-gram cooking serving of each kind: - Brown rice: 111 calories, 3 grams protein, 2 grams fiber, 0.4 milligrams iron - White rice: 130 calories, 2 grams protein, 0 grams fiber, o.2 milligrams iron -"
},
"voice": {
"languageCode": "en-US"
}
}
syr my bad can u set a speaker as en-US-Neural2-F
or anoter Neural2 speakers A. B C ... J
u will get error
Its my text problem in that text
' In resuming your consultations for the general good you can not but derive encouragement from the reflection that the measures of the last session have been as satisfactory to your constituents as the novelty and difficulty of the work allowed you to hope. Still further to realize their expectations and to secure the blessings which a gracious Providence has placed within our reach will in the course of the present important session call for the cool and deliberate exertion of your patriotism, firmness, and wisdom. Among the many interesting objects which will engage your attention that of providing for the common defense will merit particular regard. To be prepared for war is one of the most effectual means of preserving peace. A free people ought not only to be armed, but disciplined; to which end a uniform and well-digested plan is requisite; and their safety and interest require that they should promote such manufactories as tend to render them independent of others for essential, particularly military, supplies. The proper establishment of the troops which may be deemed indispensable will be entitled to mature consideration. In the arrangements which may be made respecting it it will be of importance to conciliate the comfortable support of the officers and soldiers with a due regard to economy. There was reason to hope that the pacific measures adopted with regard to certain hostile tribes of Indians would have relieved the inhabitants of our southern and western frontiers from their depredations, but you will perceive from the information contained in the papers which I shall direct to be laid before you (comprehending a communication from the Commonwealth of Virginia) that we ought to be prepared to afford protection to those parts of the Union, and, if necessary, to punish aggressors. The interests of the United States require that our intercourse with other nations should be facilitated by such provisions as will enable me to fulfill my duty in that respect in the manner which circumstances may render most conducive to the public good, and to this end that the compensation to be made to the persons who may be employed should, according to the nature of their appointments, be defined by law, and a competent fund designated for defraying the expenses incident to the conduct of foreign affairs. Various considerations also render it expedient that the terms on which foreigners may be admitted to the rights of citizens should be speedily ascertained by a uniform rule of naturalization. Uniformity in the currency, weights, and measures of the United States is an object of great importance, and will, I am persuaded, be duly attended to. The advancement of agriculture, commerce, and manufactures by all proper means will not, I trust, need recommendation; but I can not forbear intimating to you the expediency of giving effectual encouragement as well to the introduction of new and useful inventions from abroad as to the exertions of skill and genius in producing them at home, and of facilitating the intercourse between the distant parts of our country by a due attention to the post-office and post-roads. Nor am I less persuaded that you will agree with me in opinion that there is nothing which can better deserve your patronage than the promotion of science and literature. Knowledge is in every country the surest basis of public happiness. In one in which the measures of government receive their impressions so immediately from the sense of the community as in ours it is proportionably essential. To the security of a free constitution it contributes in various ways--by convincing those who are intrusted with the public administration that every valuable end of government is best answered by the enlightened confidence of the people, and by teaching the people themselves to know and to value their own rights; to discern and provide against invasions of them; to distinguish between oppression and the necessary exercise of lawful authority; between burthens proceeding from a disregard to their convenience and those resulting from the inevitable exigencies of society; to discriminate the spirit of liberty from that of licentiousness--cherishing the first, avoiding the last--and uniting a speedy but temperate vigilance against encroachments, with an inviolable respect to the laws. Whether this desirable object will be best promoted by affording aids to seminaries of learning already'
its my response object
{'input': text: " In resuming your consultations for the general good you can not but derive encouragement from the reflection that the measures of the last session have been as satisfactory to your constituents as the novelty and difficulty of the work allowed you to hope. Still further to realize their expectations and to secure the blessings which a gracious Providence has placed within our reach will in the course of the present important session call for the cool and deliberate exertion of your patriotism, firmness, and wisdom. Among the many interesting objects which will engage your attention that of providing for the common defense will merit particular regard. To be prepared for war is one of the most effectual means of preserving peace. A free people ought not only to be armed, but disciplined; to which end a uniform and well-digested plan is requisite; and their safety and interest require that they should promote such manufactories as tend to render them independent of others for essential, particularly military, supplies. The proper establishment of the troops which may be deemed indispensable will be entitled to mature consideration. In the arrangements which may be made respecting it it will be of importance to conciliate the comfortable support of the officers and soldiers with a due regard to economy. There was reason to hope that the pacific measures adopted with regard to certain hostile tribes of Indians would have relieved the inhabitants of our southern and western frontiers from their depredations, but you will perceive from the information contained in the papers which I shall direct to be laid before you (comprehending a communication from the Commonwealth of Virginia) that we ought to be prepared to afford protection to those parts of the Union, and, if necessary, to punish aggressors. The interests of the United States require that our intercourse with other nations should be facilitated by such provisions as will enable me to fulfill my duty in that respect in the manner which circumstances may render most conducive to the public good, and to this end that the compensation to be made to the persons who may be employed should, according to the nature of their appointments, be defined by law, and a competent fund designated for defraying the expenses incident to the conduct of foreign affairs. Various considerations also render it expedient that the terms on which foreigners may be admitted to the rights of citizens should be speedily ascertained by a uniform rule of naturalization. Uniformity in the currency, weights, and measures of the United States is an object of great importance, and will, I am persuaded, be duly attended to. The advancement of agriculture, commerce, and manufactures by all proper means will not, I trust, need recommendation; but I can not forbear intimating to you the expediency of giving effectual encouragement as well to the introduction of new and useful inventions from abroad as to the exertions of skill and genius in producing them at home, and of facilitating the intercourse between the distant parts of our country by a due attention to the post-office and post-roads. Nor am I less persuaded that you will agree with me in opinion that there is nothing which can better deserve your patronage than the promotion of science and literature. Knowledge is in every country the surest basis of public happiness. In one in which the measures of government receive their impressions so immediately from the sense of the community as in ours it is proportionably essential. To the security of a free constitution it contributes in various ways--by convincing those who are intrusted with the public administration that every valuable end of government is best answered by the enlightened confidence of the people, and by teaching the people themselves to know and to value their own rights; to discern and provide against invasions of them; to distinguish between oppression and the necessary exercise of lawful authority; between burthens proceeding from a disregard to their convenience and those resulting from the inevitable exigencies of society; to discriminate the spirit of liberty from that of licentiousness--cherishing the first, avoiding the last--and uniting a speedy but temperate vigilance against encroachments, with an inviolable respect to the laws. Whether this desirable object will be best promoted by affording aids to seminaries of learning already"
, 'voice': language_code: "en-US"
name: "en-US-Neural2-J"
, 'audio_config': audio_encoding: MP3
}
its my code sample, and its give back a response invalid request 400
def get_audio(text,API_SPEAKER): # added below text 'en-US-Neural2-J'
client = texttospeech.TextToSpeechClient()
input_text = texttospeech.SynthesisInput(text=text)
voice = texttospeech.VoiceSelectionParams(
language_code="en-US",
name=API_SPEAKER ,
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3
)
request={"input": input_text, "voice": voice, "audio_config": audio_config}
response = client.synthesize_speech(
request
)
its related by text because of only text change on that function and some text like this give back error on api and also give error on web gui IMPORTANT NOTE for error u must be set speaker 'en-US-Neural2-J' (or another en-USNeural2-* speaker ! ) if dont send spekaer its working correctly
Also ı have receive same error on google web page for test text2speach api --> https://cloud.google.com/text-to-speech if im paste my malicious text in that page and chose voice type Neural2 taht page frozen and text2speach api request receive 400 on browser Im explain my problem on that video --> https://somup.com/c0nV0uxzT7
I don't understand what the problem is here, what is the problem with this text, why doesn't the api accept this text? Are there any special characters I need to clear in this text?
Im also remove all special chracters and still receive 400 in that text
In resuming your consultations for the general good you can not but derive encouragement from the reflection that the measures of the last session have been as satisfactory to your constituents as the novelty and difficulty of the work allowed you to hope Still further to realize their expectations and to secure the blessings which a gracious Providence has placed within our reach will in the course of the present important session call for the cool and deliberate exertion of your patriotism firmness and wisdom Among the many interesting objects which will engage your attention that of providing for the common defense will merit particular regard To be prepared for war is one of the most effectual means of preserving peace A free people ought not only to be armed but disciplined to which end a uniform and welldigested plan is requisite and their safety and interest require that they should promote such manufactories as tend to render them independent of others for essential particularly military supplies The proper establishment of the troops which may be deemed indispensable will be entitled to mature consideration In the arrangements which may be made respecting it it will be of importance to conciliate the comfortable support of the officers and soldiers with a due regard to economy There was reason to hope that the pacific measures adopted with regard to certain hostile tribes of Indians would have relieved the inhabitants of our southern and western frontiers from their depredations but you will perceive from the information contained in the papers which I shall direct to be laid before you comprehending a communication from the Commonwealth of Virginia that we ought to be prepared to afford protection to those parts of the Union and if necessary to punish aggressors The interests of the United States require that our intercourse with other nations should be facilitated by such provisions as will enable me to fulfill my duty in that respect in the manner which circumstances may render most conducive to the public good and to this end that the compensation to be made to the persons who may be employed should according to the nature of their appointments be defined by law and a competent fund designated for defraying the expenses incident to the conduct of foreign affairs Various considerations also render it expedient that the terms on which foreigners may be admitted to the rights of citizens should be speedily ascertained by a uniform rule of naturalization Uniformity in the currency weights and measures of the United States is an object of great importance and will I am persuaded be duly attended to The advancement of agriculture commerce and manufactures by all proper means will not I trust need recommendation but I can not forbear intimating to you the expediency of giving effectual encouragement as well to the introduction of new and useful inventions from abroad as to the exertions of skill and genius in producing them at home and of facilitating the intercourse between the distant parts of our country by a due attention to the postoffice and postroads Nor am I less persuaded that you will agree with me in opinion that there is nothing which can better deserve your patronage than the promotion of science and literature Knowledge is in every country the surest basis of public happiness In one in which the measures of government receive their impressions so immediately from the sense of the community as in ours it is proportionably essential To the security of a free constitution it contributes in various waysby convincing those who are intrusted with the public administration that every valuable end of government is best answered by the enlightened confidence of the people and by teaching the people themselves to know and to value their own rights to discern and provide against invasions of them to distinguish between oppression and the necessary exercise of lawful authority between burthens proceeding from a disregard to their convenience and those resulting from the inevitable exigencies of society to discriminate the spirit of liberty from that of licentiousnesscherishing the first avoiding the lastand uniting a speedy but temperate vigilance against encroachments with an inviolable respect to the laws Whether this desirable object will be best promoted by affording aids to seminaries of learning already
Update: if am i dvide that text 500 bytes pices and send api its working (but api documentation say api accpe up to 5000 bytes )
any body here ?
To fix this error, add periods so the input is multiple smaller sentences.
To fix this error, add periods so the input is multiple smaller sentences.
im already this but google text2speach add slience parts end of result mp3 file and its not good for my case (im remove parts using ffpmeg but ıts need carryfully management on code side)
I have the same issue for long requests, tested all the SDKs up to 2.13.0 - saw someone having the same issue with the node sdk. It does not seem to be an issue with your text, tested multiple variations of the same.
The output is generated correctly in the bucket.
def sample_synthesize_long_audio():
# Create a client
client = texttospeech_v1.TextToSpeechLongAudioSynthesizeClient.from_service_account_file(
'key.json')
# Initialize request argument(s)
input = texttospeech_v1.SynthesisInput()
input.text = "hello."
audio_config = texttospeech_v1.AudioConfig(
audio_encoding=texttospeech_v1.AudioEncoding.MP3
)
voice = texttospeech_v1.VoiceSelectionParams(
name="en-US-Standard-C",
language_code="en-US",
# ssml_gender=texttospeech_v1.SsmlVoiceGender.FEMALE
)
request = texttospeech_v1.SynthesizeLongAudioRequest(
input=input,
audio_config=audio_config,
voice=voice,
output_gcs_uri="gs://mybucket/object.mp3"
)
# Make the request
operation = client.synthesize_long_audio(request=request)
print(operation.result())
and the error
Traceback (most recent call last):
File "/Users/nick/Development/text-to-speech/env/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 72, in error_remapped_callable
return callable_(*args, **kwargs)
File "/Users/nick/Development/text-to-speech/env/lib/python3.9/site-packages/grpc/_channel.py", line 1030, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/Users/nick/Development/text-to-speech/env/lib/python3.9/site-packages/grpc/_channel.py", line 910, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "UNKNOWN:Error received from peer ipv6:=....:443 {created_time:"2023-04-02T19:24:02.289937-06:00", grpc_status:3, grpc_message:"Request contains an invalid argument."}"
We've identified that
audio_config = texttospeech_v1.AudioConfig(
audio_encoding=texttospeech_v1.AudioEncoding.MP3
)
is not being honoured (same for node sdk) and that could be what is triggering the error, both sdks are behaving similarly.
Reclassifying as a bug based on the above comment.
I'm going to transfer this issue to google-cloud-python as we're prepared to migrate the code from this repository there in the next 1-2 weeks.