A train from La Spezia to Florence is certainly a possibility, but you should have enough time to do it. A train ride takes between 110 and 130 minutes. Count on about € 17 per person (one way). There run at least 1 to 2 trains per hour. Most trains also make a brief stop in Pisa, but it's unlikely that you will have enough time to make a quick city visit on your way back. Before you leave, better check the timetable from the train between La Spezia and Florence.
How do I get to the train station from the cruise port in La Spezia?
The La Spezia Centrale Train Station is located 4km from the port. If you are short of time better take a taxi to the train station.