The president of India, picking up a theme that has been sounded ever more frequently here, warned in a nationally televised address tonight that the continuation of democracy in this country is threatened by increasing violence and a growing lack of morality at all levels of government.

"Unless we take immediate action to arrest the disregard of moral values in public life, people's faith in our political system will be undermined with consequences which are too frightening to contemplate," said N. Sanjiva Reddy, India's head of state, in what appeared to be a direct challenge to the government of Prime Minister Indira Gandhi.

Reddy's speech on the eve of the 32d anniversary of the birth of the republic echoed cries of gloom that have been coming with increasing frequency over the future of the world's largest democracy.

"Chaos will engulf the republic of India within the next 10 years," wrote the former editor of the Hindustan Times, Hiranmay Karlekar, in an analysis of the country's malaise in Sunday's India Express, the newspaper that has been most vocal in its opposition to the Gandhi government.

The same theme appeared Sunday in the progovernment Times of India, whose editor, Girilal Jain, a Gandhi supporter, wrote of "the decline of the political process which is the heart of a healthy democracy."

These and other analyses have focused on an increase in political corruption--a subject to which Reddy alluded but did not directly address.

Political corruption has been haunting the Gandhi administration as even longtime admirers have publicly charged that a decay in the morality of government coincided with her coming to power. There are frequent charges that her political associates demand payments for such scarce commodities as cement.

The former Indian ambassador to the United States, B.K. Nehru, for example, made a widely quoted speech last month in which he charged that corruption permeates the government from top to bottom.

"An uncomfortably large number of politicians and ministers are corrupt," said Nehru, who is a cousin of Gandhi and the man she picked to be a special envoy to bring a message to President Reagan soon after he was elected.

"Corruption is universal in the lower ranks of the public service," he said. "It has affected the middle ranks as well and is now infecting the apex of our administrative structure, the All-India Service the country's top civil service ranks , which used at one time to be wholly above suspicion."

The focus of much of the corruption charge has been A.R. Antulay, Gandhi's selection as chief minister of the state of Maharashtra, which includes the city of Bombay. Antulay was forced to resign this month after a civil court implicated him in a scandal involving the exchange of million of dollars in donations to a private trust for increased allocations of cement and other scarce materials.

Although commentators have pointed to increased corruption within the once-sacred civil service, partly due to its politicalization by Gandhi, most attacks have centered on growing dishonesty among elected political figures.

Reddy contrasted the venal nature of most of today's politicians with the selflessness of those who made financial sacrifices to aid the freedom struggle.

Reddy's speech took on added importance since it came at a time when India generally celebrates its triumphs instead of broadcasting its weaknesses.

Traditionally, the president, who holds a largely powerless ceremonial position modeled after a king in a constitutional monarchy, clears his public speeches with the prime minister.

But Reddy increasingly has been making harsh criticisms of the Gandhi government that appear to be purely his own opinion. As he approaches the final six months of his term, he appears to be attempting to emerge as the conscience of India. In a speech to the Indian Medical Association, for example, he delivered the first and last paragraphs of his prepared text and spent the rest of the time ad libbing an indictment of the poor state of health care for most Indians.

A confidant of Gandhi said today that the government sometimes has to let Reddy go off on his own, especially if he is not speaking on delicate policy issues.

But Reddy, who says he is retiring from politics to return to his village as a farmer when his term ends, has been increasingly critical of the government in speeches over the past six months and Gandhi reportedly has referred to him as part of the opposition.

While Reddy helped form the Janata coalition that overthrew a previous Gandhi government in 1977 and was elected president during the 33 months of Janata rule, he has been largely nonpolitical.

Although he has no political following at the moment, Reddy, 68, is widely respected for his role in the independence struggle. He joined Mahatma Gandhi in the drive to gain independence for India that culminated in 1947 when Britain freed its former colony. The republic was formed 2 1/2 years later.

"What we find now," Reddy said tonight, "is the very antithesis of the noble spirit that animated the nation only a few decades ago."

"May I fervently appeal to all political parties to do some heart searching and endeavor to bring about a regeneration of moral values in our public life," he said.

While listing some of India's successes over the past 34 years, especially its industrial development and its new-found ability to feed itself, Reddy also detailed the failures that have plagued the nation, which is listed by the World Bank as the 15th poorest.

"The fruits of development are beyond the reach of a large number" of India's 680 million people, he said. "Unemployment and underemployment continue to dog us. Per capita income averaging under $200 a year and per capita availability of many essential articles are far short of the goals we had set for ourselves."

While he acknowledged that external threats and massive population increases that have doubled since independence had held the country back, Reddy laid much of the blame for India's lack of progress on the nation's inefficiency.

That charge was especially pointed since Gandhi and her father, India's first prime minister, Jawaharlal Nehru, have run the country for all but five years of its existence as an independent state.

In the political sphere, Reddy called for "due consideration" by the Gandhi government for a "reasonable and responsible opposition."

In recent statements, Gandhi has attacked unity moves by the splintered opposition and accused its members of having no other aim but to overthrow her government as it did in 1977.

"For the healthy functioning of a democracy, a strong and responsible opposition is prerequisite," said Reddy in what looked like a rebuttal to the prime minister.