This is the shocking moment a city's public speaker system started blasting out porn in the middle of the night.

Police are investigating after the adult soundtrack was heard from government loudspeakers in the city of Kastamonu in northern Turkey's Kastamonu Province.

A shocked witness, who could not believe what he was hearing, recorded it with his smartphone and posted the recording on social media.

This is the shocking moment a city's public speaker system started blasting out porn in the middle of the night

The clip, recorded from a speaker in the Kuzeykent suburb of the city, which includes the university and main bus station, quickly went viral.

The mayor of the city, Tahsin Babas, said it was caused by somebody mischievously hacking into the frequency used by the speakers.

Mayor Babas said: 'This immoral and provocative broadcast was nothing to do with our institution.

'We will take legal action as soon as we can against whoever was responsible for this immoral act.

Police are investigating after the blue movie soundtrack was heard from government loudspeakers in the city of Kastamonu (pictured) in northern Turkey's Kastamonu Province

'We can only apologise to our dear citizens for any offence caused by this incident.'

Police are investigating the porn broadcast and backed the mayor's claim that frequency hackers were responsible.

A police spokesman said: 'They broke into the frequencies used by the municipal speaker which is why the sounds appeared in only one area.

'Anybody who can break into the frequency can broadcast anything they want. We have started an investigation.'