Pigs have appeared in films before. They run squealing through Western towns when the bad guys arrive. They lie on banqueting tables in costume dramas with apples in their mouths. One even got into a fight with Dame Maggie Smith, and lost. What they don’t do is talk. Until Babe.

Babe, the story of a pleasantly articulate piglet with unusual ambitions, comes to us straight from astonishing success in America. Not only has it brought home the bacon to the tune of $55m, this Australian picture has had the critics rolling over in the mud and kicking their trotters in the air. The New York Times called it “a porcine public relations coup”. The Los Angeles Times said it was “irresistible”, although it also felt it had to warn the parents of sensitive little Angelenos that it included “talk about animal mortality”. Well, that’s farming for you.

“It is brilliantly done,” says Dick King Smith, the British author of the book upon which the film is based. “When my wife and I saw it we were quite easily able to persuade ourselves that they’d actually taught the animals to speak.”

In Babe, real animals take all the key roles. There is the eponymous hero, a piglet, but also dogs, sheep, a cat and a wise-cracking New York duck. A couple of humans, the American television stalwart James Cromwell as the taciturn Farmer Hogget and Australian comedienne Magda Szubanski as his voluble wife, provide excellent support. It’s a remarkable adaptation of King Smith’s story, The Sheep-Pig, which tells of a piglet who is adopted by a kindly border collie and learns the craft of herding sheep.

King-Smith was a soldier, a farmer, a travelling salesman, a time-and-motion man in a shoe factory and a schoolteacher before, at 60, he became a full-time children’s author: The Sheep-Pig , his fifth book, was the first fruit of that career-change. Now 73, he has written 80 titles (“Some of them are little short books for little short people,” he says) of which more than three quarters have featured talking animals: “It isn’t cheating in any way,” he says, good-humouredly. “You’re allowed to do it.”

George Miller, the Australian director and producer perhaps best known for the apocalyptic Mad Max, first heard about King Smith’s gentle West Country fable when it was reviewed on the children’s audio channel of a flight into London. Intrigued, he bought a copy of the book and then the film rights. He showed it to Chris Noonan, a young Australian film-maker then best known for documentary work.

“I thought it was extraordinary,” says Noonan, “In that what on the surface is a simple little children’s story, a story that’s charming and whimsical, had a lot of other layers to it, a lot of depth to it. It was talking about the sort of issues that are the source of many of the problems of the world: issues like prejudice, and so on.”

King Smith takes this sort of thing in his stride. “Yes,” he says, cautiously. “People who write anthropomorphic stories like I do are terribly liable to be accused of comments upon the human condition. When I was writing the story I think it was much more practical than that. I was merely working with my farmer’s hat on, as it were, and saying, ‘If sheep object to sheepdogs because they have no manners, perhaps another animal which was more courteous would have better luck with them?’ ”

And Babe is an extremely courteous pig, well mannered and nicely spoken. From the beginning, speech was going to be the key to the project. Animation would have made things easier, but that would have labelled Babe as purely a children’s film. Miller and Noonan had greater ambitions than that. They took a year writing a script that kept closely to King Smith’s plot and atmosphere but added new characters, a host of new incidents and a slightly darker tone. Then they looked for the technology to make it happen.

“Although it would have been possible to have all the animals do all their actions that you see in the film,” says Noonan, “It wouldn’t have been possible to have their dialogue until very recently.”

Three main techniques are involved: animal training, computer graphic animation and animatronics (high-technology puppets packed with electronics). Animal training, though, provides the narrative spine upon which everything else hangs.

“In the picture as originally scheduled it was just over 50 per cent live animal action and the rest animatronics and animation,” says Karl Lewis Miller, charged with marshalling and training the 970 animals involved in the film. “However, to Chris Noonan’s delight, and I think George Miller’s surprise, the live animals really did much more than anybody expected.”

To get those performances required extraordinary planning. The first time he tried, it took Miller 26 weeks to teach a pig to do everything in the script, by which time the animal was more than two feet tall and 10 stone in weight: Babe was supposed to be half that size.

Later he was able to speed up the training period, but there were other complications. Because of the pigs’ growth rate, they only stayed the right size for the part for three weeks: after that they outgrew the animatronic doubles used for close-up work. And filming is much too demanding for just one pig at a time. So Miller asked a piggery to supply near-identical thoroughbred Large White piglets in batches of six from the same litter. Every three weeks another group arrived.

Bringing four colleagues from his base in Hollywood, and hiring nearly 50 people locally, Miller began the training programme. He started work in the heart of Sydney, before moving out to a pair of purpose-built barns on the set, in a lush but empty valley near the tiny town of Robertson, New South Wales.

The pigs arrived at three weeks old for an 11-week training programme. As soon as the first batch (Angie, Annie, Arlene…) entered their third week of training, a second batch (Barbara, Billie, Beth…) would arrive, then a third three weeks later and so on.

In all, Babe was played by 48 pigs. Animal actors are motivated by food. Once they are full, they lose concentration and a photographic double has to step in. Each pig would be fed in instalments to tease out his performance (or rather hers, since despite being a male character, Babe is played throughout by female porkers).

But there is more to it than that. “Every pig was trained to do the whole movie,” says Miller. “But each pig learned it and did it in his own way. If the scene said ‘The pig jumped into a chair and sat at attention and oinked two times’, in training we’d train six pigs to do that. Now each pig would do it a little bit different.

“Now what happens when we go to do the scenes, we decide what the animal’s character in this shot is. We use the pig that does it with that flavour, that attitude. This way we could control the pig’s character and personality in the script, and that would tell us which pig to use for the shot.”

Lots of other animals had to be trained, with varying degrees of difficulty. But the pigs were crucial: apart from being at ease with humans and performing various tricks, from walking up a plank to crawling under a fence, they also had to learn not to be too pig-like.

“He never ever ate off the ground or learned to sniff and rummage for his food,” says Miller. “We didn’t want the audience distracted by that animal quality, we wanted to give it a human child-like character and we accomplished that by not letting it show that animal instinct to be sniffing.”

The complexity of the animal work was as nothing to the computer graphics technology, which took a hefty slice of the film’s $25m budget. A process called “morphing” was used. First the animals were filmed, performing the actions and displaying body language to match the dialogue in the script.

A 3D ‘model’ of the animal’s face was then produced in a computer, animated to make it speak the words on the soundtrack, and ‘painted’ with the photographic textures of the actual pig used in the shot. The model was then merged back into the film. It’s all massively more complicated than that, of course.

These innovative computer effects were partnered with animatronic puppetry. Jim Henson’s Creature Shop, based in London, built pigs and dogs, and sheep were created by an Australian firm. “It is completely groundbreaking work,” says Noonan, “Because whereas it’s very common to make animatronics of fantasy characters, it’s extremely rare to have believeable animatronics of real animals of species that we know about, like dogs and pigs.

“And there’s no greater challenge than to try and intersperse the shots of animatronics with shots of the real animals, as you’re constantly being reminded of what a real one looks like.”

Karl Lewis Miller has an unusual angle on the talking. “We never tried to say that the animals could talk English,” he insists. “What we tried to do was no different to Jesus at the Mount, talking to thousands of people in all different languages, and they could all hear Jesus talk ‘in tongues’. What we were trying to do was let the pig oink, let the cow moo, the chickens cluck and the cats miaow, but let the audience hear them in tongues.”

Despite the richness of the feelings on display, the animals are not just humans in fur, he insists. They are displaying animal emotions. “All they [the film-makers] did was emphasize them to the point where you could appreciate them. I believe dogs do cry, I think animals are shocked, I think they giggle and laugh when they are happy.

“Yes, there was a couple of places where they put just a touch of a smile on the pig’s face with the digital animation. But guess what, it was only to help the audience see it,” he insists. “In the scene, the pig was smiling. Definitely.”

The animals’ voices were provided by a human cast that included Miriam Margolyes, brought from London to play the key role of Fly, the sheepdog who adopts the young piglet. She was tracked down by George Miller, who insisted that first she fly out to Australia to meet the border collie in question.

The process of marrying voice and pictures was extremely complicated, with some characters’ dialogue recorded anything up to five times. One problem was that, after the first recording, the film-makers decided that the original British accents of both humans and some of the animals would be incomprehensible to Americans and had them redubbed in the current non-specific mid-Atlantic style.

This is not all about national prejudice. As Chris Noonan explains, “As film viewers, we are used to using a bit of lip reading with human characters to get us through moments of non-clarity, but the way we were animating the animals’ mouths was much less precise than human lip movement. In some cases we decided that greater clarity in delivery was required, so we reassessed some of the accents that had been used originally.

“Additionally, the original approach of using mainly British Isles accents was causing some debate. Our broad aim had always been to set the film in a ‘storybook’ world, which borrowed from many cultures, but was impossible to pin down to one.”

Margolyes is a veteran of animal parts: she once did the PG Tips monkeys. She found the new brief, to produce an unidentifiable rural accent, a slightly tricky one. But in general she is not one to agonise about how a dog ought to speak.

“I was completely sure that a dog speaks like a person,” she says, wryly. “I don’t believe that you have to put on funny voices to make a character happen. I’ve worked in radio for 30 years and my experience had taught me that people who are listening do a lot of the work themselves. What finishes the job for me in this film is the dog herself.”

“I’m extremely proud of this film, I really am,” she says. “I think in a way it’s a kind of allegory of life. It’s not just a children’s story, it’s something that grown-ups can appreciate.

“The script is remarkable. If you remember the first few words of it, the voiceover says ‘This is the tale of an unprejudiced heart.’ That’s a fairly remarkable thing to open a children’s film with. It doesn’t talk down to anybody.”

Babe has taken some $55m in the States, enough to bring Chris Noonan an immediate invitation to do “Babe II”, something he doesn’t immediately relish. “I’m much more interested in doing more conventional movies, not in story terms, but in technical terms,” he says, understandably.

And what of the animal stars? “When they were done,” says Karl Lewis Miller, “We kept them for a few extra days and started letting them eat out of bowls and off the ground. Then we gave them back to the breeders to become breed pigs, sow pigs. We actually made agreements with these breeders that none of them were meant for the table, that they would all go on to be sow pigs and do what little pigs like to do: to raise other little baby pigs.”

For a children’s film about talking farm animals, though, Babe is fairly explicit about where such creatures usually end up. It opens with a terrifying factory farm scene, of Noonan and Miller’s invention. And even in King Smith’s rather gentler book, the dinner table is never far away. “I write from the point of view of a total hypocrite,” he says, disarmingly. “Which is somebody who loves pigs alive and loves pigs dead.”

Nor is Karl Lewis Miller any sort of vegetarian. “No, I’m not,” he says. “But I’ve never eaten a friend, I can tell you that.”