-- ----------------------------------------------------------------------------
-- Copyright (C) 2012 Nokia Gate5 GmbH Berlin
--
-- These coded instructions, statements, and computer programs contain
-- unpublished proprietary information of Nokia Gate5 GmbH Berlin, and
-- are copy protected by law. They may not be disclosed to third parties
-- or copied or duplicated in any form, in whole or in part, without the
-- specific, prior written permission of Nokia Gate5 GmbH Berlin.
-- ----------------------------------------------------------------------------
--      Author: Fabian TP Riek
-- ----------------------------------------------------------------------------
--      Output format for Windows Phone w/ MSFT Engine
--      0.4.0.XXX

Platform = {}

Platform.take_phoneme_if_exits = function( article, name, phoneme )
	if use_phoneticdata
		and ( string.find( name, "%d") == nil )
		and phoneme ~= nil
		and phoneme ~= ""
	then
		return article.." <break time=\"0.15s\"/><phoneme alphabet=\"ipa\" ph=\""..phoneme.."\">"..name.."</phoneme> "
	else
		return article.." <break time=\"0.15s\"/><say-as interpret-as=\"address\">"..name.."</say-as> "
	end
end


Platform.build_streetname = function( street_name, r_sentence )
	if street_name == "" or street_name == nil then
		return ""
	end

	article = add_street_article( street_name, r_sentence )
	phoneme = add_phonetic_data( street_name )
	name = expand_dgttsp( street_name, r_sentence )

	return Platform.take_phoneme_if_exits( article, name, phoneme )
end


Platform.build_signpost = function( signpost_name, r_sentence )
	if signpost_name == "" or signpost_name == nil then
		return ""
	end

	phoneme = add_phonetic_data( signpost_name )
	name = expand_dgttsp( signpost_name, r_sentence )

	return Platform.take_phoneme_if_exits( "", name, phoneme )
end


function set_result( id )

	if nonTTS and double_command and id == command_id_1 and commands_double[ id ] ~= nil and commands_double[ id ] ~= "" then
		result_sentence = commands_double[ id ]
	elseif guidance_mode == "pedestrian" and commands_ped[ id ] ~= nil and commands_ped[ id ] ~= "" then
		result_sentence = commands_ped[ id ]
	else
		result_sentence = commands_common[ id ]
	end

	if result_sentence == nil or result_sentence == "" then
		result_sentence = " "
	end

	if result_sentence ~= nil and result_sentence ~= " " and not nonTTS then

		tts_street_1 = Platform.build_streetname(tts_street_1, result_sentence)
		tts_street_2 = Platform.build_streetname(tts_street_2, result_sentence)

		tts_signpost_1 = Platform.build_signpost(tts_signpost_1, result_sentence)
		tts_signpost_2 = Platform.build_signpost(tts_signpost_2, result_sentence)


		if exit_number ~= "" and exit_number ~= nil then
			exit_number = " <say-as interpret-as=\"address\">"..exit_number.."</say-as> "
		end

		tts_street_1 = SSML_avoid_break_in_say_as( tts_street_1 )
		tts_street_2 = SSML_avoid_break_in_say_as( tts_street_2 )
		tts_signpost_1 = SSML_avoid_break_in_say_as( tts_signpost_1 )
		tts_signpost_2 = SSML_avoid_break_in_say_as( tts_signpost_2 )

		--audio_mode = '